Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.35 KB | None | 0 0
  1. @name all in one tank chip by dakota V36 Rick edit
  2. @inputs Turret:entity Pod:wirelink CamController:wirelink Gun:entity Gun2:entity W A S D Space Scope CamToggle Engine:entity
  3. @outputs [ANGLE CLAMPANG]:angle [HitPosition HitPosition2]:vector Throttle GearOut GearTC LgearTC RgearTC LgearOut RgearOut Lclutch Rclutch HardBrake Zoom
  4. @persist Gear Lgear Rgear GEARTIME Speed Active Dualclutch Dualgearbox Rev CamToggle ThirdPerson FirstPerson CAMTIME
  5. @persist Brakepower Turnpower Twospeed Fourspeed Sixspeed Eightspeed ThirdPos:vector ThirdDist FirstPos:vector FirstDist
  6. @persist Seat:entity MainHoloColor:vector CupolaHoloColor:vector RotateWithHull WheelCount WheelModel:string Wheels:array EntAng:angle LocAng:angle Y P ReloadSound:string TreadSound:string TurretSound:string RotationSpeed CupolaRotationSpeed POS:vector ANG:angle Tank:array HOLDANG Elevation Depression YawMin YawMax CupolaElevation CupolaDepression CupolaYawMin CupolaYawMax Cupola ShiftTime TransferCase Magnification HoloMarker
  7. @trigger
  8. if(first()|dupefinished()){
  9. #Instructions - Revision 36
  10. #EDITED FOR RICK's
  11.  
  12. #MAKE SURE E2 ARROW POINTS FORWARD!
  13. #IMPORTANT: if you want the camera to work then the only thing you should check is to have
  14. #client side movement checked, though you can have the extras checked without any issue
  15. #for example: auto unclipping and hide player, you can set client side movement if you want,
  16. #but I setup extra view modes and a section to change them if you understand how.
  17.  
  18. #Wire Turret to an entity marker that marks the baseprop of the turret (or use the gun if you are using a tank destroyer)
  19. #Wire Pod to the pod controller
  20. #Wire CamController to the cam controller
  21. #Wire Gun to the gun
  22. #Wire Gun2 to the second gun if you have one and are using two of the same gun side by side
  23. #Wire Throttle on the engine to Throttle
  24. #Wire W,A,S, and D to W,A,S, and D on the pod controller
  25. #Wire Engine to the engine (or one of the engines)
  26. #Wire CamToggle to your preference of key on the pod controller, this swaps views
  27. #Wire FOV on the cam controller to Zoom on the e2
  28. #Wire Scope to your preference of key on the pod controller, this zooms in when held
  29.  
  30. #dual clutch instructions
  31. #Wire Gear on the dual clutch gearbox to GearOut
  32. #Wire Right clutch and Right brake on the gearbox to Rclutch
  33. #Wire Left clutch and Left brake on the gearbox Lclutch
  34.  
  35. #dual gearbox instructions
  36. #Wire Gear on the left gearbox to LgearOut
  37. #Wire Gear on the right gearbox to RgearOut
  38. #Wire clutch and brake on the left gearbox to Lclutch
  39. #Wire clutch and brake on the right gearbox to Rclutch
  40.  
  41. #transfer case for reverse instructions
  42. #Wire Gear on the transfer case to GearTC
  43. #if two transfer cases
  44. #Wire Gear on the left transfer case to LgearTC
  45. #Wire Gear on the right transfer case to RgearTC
  46.  
  47. #tips
  48. #for crosshairs use an advanced hud indicator and link worldpos to HitPosition on the e2
  49. #by default the camera is first person, set a key for toggling to go to third
  50.  
  51. #this is the beginning of the section you modify, just select things
  52. #and read instructions and you will be fine.
  53.  
  54. #is it dual clutch or dual gearbox?
  55. Dualclutch = 1 #1 if dual clutch 0 if not
  56. Dualgearbox = 0 #1 if dual gearbox 0 if not
  57.  
  58. #enable if you use a transfercase to reverse that is connected to another gearbox that only goes forward
  59. TransferCase = 0
  60.  
  61. #how many gears do you have? only place a 1 by one option
  62. Twospeed = 0 #Transfer cases or CVTs
  63. Fourspeed = 0 # 4-speed gearbox
  64. Sixspeed = 0 # 6-speed gearbox
  65. Eightspeed = 1 # 8-speed gearbox
  66.  
  67. #These are for the turning and braking power of the vehicle,
  68. #lower them if you spaz, raise them if you want to turn or brake faster
  69. Turnpower = 20 #turning power
  70. Brakepower = 20 #braking power
  71.  
  72. #do you want the engine to rev while idle or not
  73. Rev = 0 #this is good for quick starts but can be loud and is horrible on fuel
  74. #NOTE: best used with multiple engines if a cvt is used
  75.  
  76. #time in milliseconds*interval between gear shifts
  77. ShiftTime = 5
  78.  
  79. #Set to 1 if the secondary gun is mounted on a secondary turret
  80. Cupola = 0
  81.  
  82. RotationSpeed = 5.0 #how fast the turret can rotate. Consider that 1.0 = 10degrees/second
  83. CupolaRotationSpeed = 20.0 #how fast the secondary turret can rotate
  84. RotateWithHull = 0 #Set this to one if you want the turret to rotate with the hull
  85.  
  86. #Zoom Options
  87. Magnification = 30 #Scope's zoom value - goes from 1 to 90, 1 is highest zoom, 90 is lowest, set higher for low vel projectiles
  88.  
  89. #NOTE: have the e2 arrow point forward
  90. #Don't set any of these to negatives or things break
  91. Elevation = 15 #How High you can aim up
  92. Depression = 7 #How low you can aim down
  93. YawMin = 360 #How far your turret can spin Left
  94. YawMax = 360 #How far your turret can spin right
  95. #---Shit under this is for if you have a mini turret on your turret---#
  96. CupolaElevation = 55 #Up
  97. CupolaDepression = 15 #Down
  98. CupolaYawMin = 360 #Right
  99. CupolaYawMax = 360 #Left
  100.  
  101. #Crosshair toggle: set this to 1 if you want a hologram to mark the point the gun is aiming at, this doesn't account for speed when fired or bullet drop.
  102. HoloMarker = 0
  103. MainHoloColor = vec(255,0,0)
  104. CupolaHoloColor = vec(0,0,255)
  105.  
  106. #Sounds
  107. TreadSound = "acf_extra/tankfx/heavy_tracks.wav"
  108. TurretSound = "acf_extra/tankfx/turret5.wav"
  109. #ReloadSound = "acf_extra/tankfx/gnomefather/reload14.wav"
  110.  
  111. #Wheel model (the road wheels)
  112. WheelModel = "models/sprops/trans/miscwheels/tank30.mdl"
  113.  
  114. #Camera Positions and distances
  115. ThirdPos=vec(0,0,160)
  116. ThirdDist=260
  117. FirstPos=vec(0,0,110)
  118. FirstDist=60
  119.  
  120. #End of things you need to change
  121.  
  122. if(HoloMarker==1){
  123. holoCreate(1,HitPosition)
  124. holoModel(1, "sphere")
  125. holoMaterial(1, "lights/white001")
  126. holoScale(1,vec(2.5,2.5,2.5))
  127. holoColor(1,MainHoloColor)
  128. if(Cupola==1){
  129. holoCreate(2,HitPosition2)
  130. holoModel(2, "sphere")
  131. holoMaterial(2, "lights/white001")
  132. holoScale(2,vec(2.5,2.5,2.5))
  133. holoColor(2,CupolaHoloColor)
  134.  
  135. }
  136.  
  137. }
  138. HOLDANG = entity():toLocal(Gun:angles()):yaw()
  139. Tank = entity():getConstraints()
  140. rangerFilter(Tank)
  141. rangerPersist(1)
  142.  
  143. entity():isWeldedTo():soundPlay(1,0,TreadSound)
  144. entity():isWeldedTo():soundPlay(2,0,TurretSound)
  145.  
  146. soundVolume(1,0)
  147. soundPitch(1,0)
  148.  
  149. Wheels = array()
  150. WheelCount = 1
  151. for(I=1,Tank:count()){if(Tank[I,entity]:model() == WheelModel){Wheels[WheelCount,entity]=Tank[I,entity],WheelCount+=1}}
  152.  
  153.  
  154. }
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. interval(100)
  163.  
  164. ChangeRPM = Engine:acfRedline()*90/100
  165. DownChangeRPM = Engine:acfPowerbandMin()
  166. Throttle=0
  167. Rclutch=0
  168. Lclutch=0
  169. if(Active==0|Rclutch+Lclutch>0){HardBrake=1}else{HardBrake=0}
  170.  
  171. Active = Pod["Active",number]
  172. Seat = Pod["Entity",entity]
  173. #if(changed(Active)){reset()}
  174. if(Active==1){
  175. if(ThirdPerson == 0 & FirstPerson == 0 & CamToggle == 0){FirstPerson = 1, ThirdPerson = 0}
  176. CAMTIME = CAMTIME - 1
  177. if(CamToggle & CAMTIME<0){
  178. if(ThirdPerson==1){FirstPerson = 1, ThirdPerson = 0, CAMTIME=10}
  179. elseif(FirstPerson==1){FirstPerson = 0, ThirdPerson = 1, CAMTIME=10}}
  180.  
  181. if(ThirdPerson){
  182. CAMPOSITION=entity():isWeldedTo():toWorld(ThirdPos)
  183. CAMDIST=ThirdDist}
  184.  
  185. elseif(FirstPerson){
  186. CAMPOSITION=Turret:toWorld(FirstPos)
  187. CAMDIST=FirstDist}
  188.  
  189. CamController["Activated", number] = Active
  190. CamController["Position", vector] = CAMPOSITION
  191. CamController["Distance", number] = CAMDIST
  192. CamController["Parent", entity] = Seat
  193.  
  194. if(!W&!S&!A&!D&!Space){Gear=0,Lgear=0,Rgear=0}
  195. if(Space){Gear=0,Lgear=0,Rgear=0}
  196. if(Gear==0){GearOut=1}else{GearOut=Gear}
  197. if(Lgear==0){LgearOut=1}else{LgearOut=Lgear}
  198. if(Rgear==0){RgearOut=1}else{RgearOut=Rgear}
  199. if(Engine:acfRPM()<ChangeRPM/4){Gear=0,Lgear=0,Rgear=0}
  200.  
  201. if(Dualclutch==1&TransferCase==0){GEARTIME = GEARTIME - 1
  202. if(S&!W&Twospeed){Gear = 2}
  203. if(!S&W&Twospeed){Gear = 1}
  204. if(Fourspeed){
  205. if(S&!W){Gear=4}else{
  206. if(W&!S&Gear==4){Gear=1}else{
  207. if(Engine:acfRPM()>ChangeRPM&Gear<=2&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  208. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=3&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}}}
  209. elseif(Sixspeed){
  210. if(S&!W){Gear=6}else{
  211. if(W&!S&Gear==6){Gear=1}else{
  212. if(Engine:acfRPM()>ChangeRPM&Gear<=4&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  213. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=5&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}}}
  214. elseif(Eightspeed){
  215. if(S&!W){Gear=8}else{
  216. if(W&!S&Gear==8){Gear=1}else{
  217. if(Engine:acfRPM()>ChangeRPM&Gear<=6&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  218. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=7&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}}}
  219. if(W|A|S|D){Throttle=100}
  220. if(A&!Space){Rclutch = Turnpower}else{Rclutch = 0}
  221. if(D&!Space){Lclutch = Turnpower}else{Lclutch = 0}
  222. if(Space){Rclutch = Brakepower}
  223. if(Space){Lclutch = Brakepower}
  224. if(!W&!S&!A&!D&!Space){Rclutch = Brakepower}
  225. if(!W&!S&!A&!D&!Space){Lclutch = Brakepower}
  226. if(!W&!S&!A&!D&!Space&Rev){Throttle = 100}}
  227.  
  228. if(Dualgearbox==1&TransferCase==0){GEARTIME = GEARTIME - 1
  229. if(A&Twospeed&!W&!S){Lgear=2,Rgear=1}
  230. elseif(D&Twospeed&!W&!S){Lgear=1,Rgear=2}
  231. elseif(A&Fourspeed&!W&!S){Lgear=4,Rgear=1}
  232. elseif(D&Fourspeed&!W&!S){Lgear=1,Rgear=4}
  233. elseif(A&Sixspeed&!W&!S){Lgear=6,Rgear=1}
  234. elseif(D&Sixspeed&!W&!S){Lgear=1,Rgear=6}
  235. elseif(A&Eightspeed&!W&!S){Lgear=8,Rgear=1}
  236. elseif(D&Eightspeed&!W&!S){Lgear=1,Rgear=8}
  237. if(!S&W&Twospeed){Lgear = 1,Rgear = 1}
  238. if(S&!W&Twospeed){Lgear = 2,Rgear = 2}
  239. if(Fourspeed){
  240. if(S&!W){Lgear=4,Rgear=4}else{
  241. if(W&!S&(Lgear==4|Rgear==4)){Rgear=1,Lgear=1}else{
  242. if(Engine:acfRPM()>ChangeRPM&Lgear<=2&Rgear<=2&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  243. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=3&Rgear<=3&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}}}
  244. if(Sixspeed){
  245. if(S&!W){Lgear=6,Rgear=6}else{
  246. if(W&!S&(Lgear==6|Rgear==6)){Rgear=1,Lgear=1}else{
  247. if(Engine:acfRPM()>ChangeRPM&Lgear<=4&Rgear<=4&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  248. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=5&Rgear<=5&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}}}
  249. if(Eightspeed){
  250. if(S&!W){Lgear=8,Rgear=8}else{
  251. if(W&!S&(Lgear==8|Rgear==8)){Rgear=1,Lgear=1}else{
  252. if(Engine:acfRPM()>ChangeRPM&Lgear<=6&Rgear<=6&!S&W&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  253. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=7&Rgear<=7&!S&W&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}}}
  254. if(W|A|S|D){Throttle=100}
  255. if(D&W|D&S){Rclutch = Turnpower}
  256. if(A&W|A&S){Lclutch = Turnpower}
  257. if(Space){Rclutch = Brakepower}
  258. if(Space){Lclutch = Brakepower}
  259. if(!W&!S&!A&!D&!Space){Rclutch = Brakepower}
  260. if(!W&!S&!A&!D&!Space){Lclutch = Brakepower}
  261. if(!W&!S&!A&!D&!Space&Rev){Throttle = 100}}
  262.  
  263. if(Dualclutch==1&TransferCase==1){GEARTIME = GEARTIME - 1
  264. if(S&!W){GearTC = 2}else{GearTC = 1}
  265. if(Twospeed){
  266. if(Engine:acfRPM()>ChangeRPM&Gear<=1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  267. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=2&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}
  268. if(Fourspeed){
  269. if(Engine:acfRPM()>ChangeRPM&Gear<=3&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  270. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=4&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}
  271. if(Sixspeed){
  272. if(Engine:acfRPM()>ChangeRPM&Gear<=5&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  273. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=6&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}
  274. if(Eightspeed){
  275. if(Engine:acfRPM()>ChangeRPM&Gear<=7&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear+1}
  276. elseif(Engine:acfRPM()<DownChangeRPM&Gear<=8&Gear>1&GEARTIME<=0){GEARTIME=ShiftTime,Gear=Gear-1}}
  277. if(W|A|S|D){Throttle=100}
  278. if(A&!Space){Rclutch = Turnpower}else{Rclutch = 0}
  279. if(D&!Space){Lclutch = Turnpower}else{Lclutch = 0}
  280. if(Space){Rclutch = Brakepower}
  281. if(Space){Lclutch = Brakepower}
  282. if(!W&!S&!A&!D&!Space){Rclutch = Brakepower}
  283. if(!W&!S&!A&!D&!Space){Lclutch = Brakepower}
  284. if(!W&!S&!A&!D&!Space&Rev){Throttle = 100}}
  285.  
  286. if(Dualgearbox==1&TransferCase==1){GEARTIME = GEARTIME - 1
  287. if(S&!W){LgearTC=2,RgearTC=2}else{RgearTC=1,LgearTC=1}
  288. if(A&Twospeed&!W&!S){LgearTC=2,RgearTC=1,Lgear=1,Rgear=1}
  289. elseif(D&Twospeed&!W&!S){LgearTC=1,RgearTC=2,Lgear=1,Rgear=1}
  290. elseif(A&Fourspeed&!W&!S){LgearTC=2,RgearTC=1,Lgear=1,Rgear=1}
  291. elseif(D&Fourspeed&!W&!S){LgearTC=1,RgearTC=2,Lgear=1,Rgear=1}
  292. elseif(A&Sixspeed&!W&!S){LgearTC=2,RgearTC=1,Lgear=1,Rgear=1}
  293. elseif(D&Sixspeed&!W&!S){LgearTC=1,RgearTC=2,Lgear=1,Rgear=1}
  294. elseif(A&Eightspeed&!W&!S){LgearTC=2,RgearTC=1,Lgear=1,Rgear=1}
  295. elseif(D&Eightspeed&!W&!S){LgearTC=1,RgearTC=2,Lgear=1,Rgear=1}
  296. if(Twospeed){
  297. if(Engine:acfRPM()>ChangeRPM&Lgear<=1&Rgear<=1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  298. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=2&Rgear<=2&Rgear>1&Lgear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}
  299. if(Fourspeed){
  300. if(Engine:acfRPM()>ChangeRPM&Lgear<=3&Rgear<=3&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  301. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=4&Rgear<=4&Rgear>1&Lgear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}
  302. if(Sixspeed){
  303. if(Engine:acfRPM()>ChangeRPM&Lgear<=5&Rgear<=5&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  304. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=6&Rgear<=6&Rgear>1&Lgear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}
  305. if(Eightspeed){
  306. if(Engine:acfRPM()>ChangeRPM&Lgear<=7&Rgear<=7&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear+1,Lgear=Lgear+1}
  307. elseif(Engine:acfRPM()<DownChangeRPM&Lgear<=8&Rgear<=8&Rgear>1&Lgear>1&GEARTIME<=0){GEARTIME=ShiftTime,Rgear=Rgear-1,Lgear=Lgear-1}}
  308. if(W|A|S|D){Throttle=100}
  309. if(D&W|D&S){Rclutch = Turnpower}
  310. if(A&W|A&S){Lclutch = Turnpower}
  311. if(Space){Rclutch = Brakepower}
  312. if(Space){Lclutch = Brakepower}
  313. if(!W&!S&!A&!D&!Space){Rclutch = Brakepower}
  314. if(!W&!S&!A&!D&!Space){Lclutch = Brakepower}
  315. if(!W&!S&!A&!D&!Space&Rev){Throttle = 100}}
  316.  
  317. if(Scope){Zoom=Magnification}else{Zoom=90}
  318.  
  319. rangerHitEntities(1)
  320. rangerFilter(Tank)
  321. HitPosition = rangerOffset(1000000,Gun:attachmentPos("muzzle"), Gun:forward()):position()
  322. if(Cupola){HitPosition2 = rangerOffset(1000000,(Gun2:attachmentPos("muzzle")), Gun2:forward()):position()}
  323.  
  324. if(HoloMarker){
  325. holoPos(1,HitPosition)
  326. holoPos(2,HitPosition2)
  327. holoVisible(1,players(),0)
  328. holoVisible(1,Seat:driver(),1)
  329. holoVisible(2,players(),0)
  330. holoVisible(2,Seat:driver(),1)
  331. }
  332.  
  333. CAM1 = CamController["CamPos", vector]
  334. CAM2 = CamController["HitPos", vector]
  335. CAMANG = CamController["CamAng", angle]
  336.  
  337. if(RotateWithHull==1){
  338. GunPos = Gun:attachmentPos("muzzle") - Gun:forward() * Gun:boxSize():x()*0.75
  339. GunAng = (rangerOffset(9999999999,CAM2,CAMANG:forward()):pos() - GunPos):toAngle()
  340. ANGLE = clamp(Gun:toLocal(GunAng),ang(-RotationSpeed),ang(RotationSpeed))+ang(0,entity():isWeldedTo():angVel():yaw()*0.12,0)
  341. CLAMPANG = clamp(entity():toLocal(Gun:toWorld(ANGLE)),ang(-Elevation,-YawMin,-1),ang(Depression,YawMax,1))
  342. Gun:applyAngForce((Gun:toLocal(entity():toWorld(CLAMPANG)) * 250 - Gun:angVel() * 30) * shiftL(ang(Gun:inertia())))
  343. if(abs(ANGLE:yaw())>1){
  344. Play = 0
  345. if(!(CLAMPANG:yaw()+1>=YawMax|CLAMPANG:yaw()-1<=-YawMin)){Play=1}
  346. }
  347. if(Cupola==1){
  348. GunPos2 = Gun2:attachmentPos("muzzle") - Gun2:forward() * Gun2:boxSize():x()*0.75
  349. GunAng2 = (rangerOffset(9999999999,CAM2,CAMANG:forward()):pos() - GunPos2):toAngle()
  350. ANGLE2 = clamp(Gun2:toLocal(GunAng2),ang(-CupolaRotationSpeed),ang(CupolaRotationSpeed))+ang(0,Turret:angVel():yaw()*0.12,0)
  351. CLAMPANG2 = clamp(entity():toLocal(Gun2:toWorld(ANGLE2)),ang(-CupolaElevation,-CupolaYawMin,-1),ang(CupolaDepression,CupolaYawMax,1))
  352. Gun2:applyAngForce((Gun2:toLocal(entity():toWorld(CLAMPANG2)) * 250 - Gun2:angVel() * 30) * shiftL(ang(Gun2:inertia())))
  353. }}
  354. else{
  355. GunPos = Gun:attachmentPos("muzzle") - Gun:forward() * Gun:boxSize():x()*0.75
  356. GunAng = (rangerOffset(9999999999,CAM2,CAMANG:forward()):pos() - GunPos):toAngle()
  357. ANGLE = clamp(Gun:toLocal(GunAng),ang(-RotationSpeed),ang(RotationSpeed))
  358. CLAMPANG = clamp(entity():toLocal(Gun:toWorld(ANGLE)),ang(-Elevation,-YawMin,-1),ang(Depression,YawMax,1))
  359. Gun:applyAngForce((Gun:toLocal(entity():toWorld(CLAMPANG)) * 250 - Gun:angVel() * 30) * shiftL(ang(Gun:inertia())))
  360. if(abs(ANGLE:yaw())>1){
  361. Play = 0
  362. if(!(CLAMPANG:yaw()+1>=YawMax|CLAMPANG:yaw()-1<=-YawMin)){Play=1}
  363. }
  364. if(Cupola==1){
  365. GunPos2 = Gun2:attachmentPos("muzzle") - Gun2:forward() * Gun2:boxSize():x()*0.75
  366. GunAng2 = (rangerOffset(9999999999,CAM2,CAMANG:forward()):pos() - GunPos2):toAngle()
  367. ANGLE2 = clamp(Gun2:toLocal(GunAng2),ang(-CupolaRotationSpeed),ang(CupolaRotationSpeed))
  368. CLAMPANG2 = clamp(entity():toLocal(Gun2:toWorld(ANGLE2)),ang(-CupolaElevation,-CupolaYawMin,-1),ang(CupolaDepression,CupolaYawMax,1))
  369. Gun2:applyAngForce((Gun2:toLocal(entity():toWorld(CLAMPANG2)) * 250 - Gun2:angVel() * 30) * shiftL(ang(Gun2:inertia())))
  370. }}
  371. }
  372. if(Active==0){
  373. interval(100)
  374. ANG=entity():toWorld(ang(0,0,0))
  375. Q=quat(ANG)/quat(Gun)
  376. Torque=Gun:toLocal(rotationVector(Q) + Gun:pos())
  377. Torque=((Torque*250) -Gun:angVelVector()* 50)*Gun:inertia()
  378. Gun:applyTorque(Torque)
  379. Gun:applyTorque(-Gun:angVelVector()*pi()/180*Gun:inertia()*1550.1*1/2)
  380. if(Cupola==1){
  381. ANG2=entity():toWorld(ang(0,0,0))
  382. Q2=quat(ANG2)/quat(Gun2)
  383. Torque2=Gun2:toLocal(rotationVector(Q2) + Gun2:pos())
  384. Torque2=((Torque2*250) -Gun2:angVelVector()* 50)*Gun2:inertia()
  385. Gun2:applyTorque(Torque2)
  386. Gun2:applyTorque(-Gun2:angVelVector()*pi()/180*Gun2:inertia()*1550.1*1/2)
  387. }
  388. Rclutch = Brakepower
  389. Lclutch = Brakepower
  390. }
  391. #treads
  392. Vel = entity():isWeldedTo():vel()
  393. Speed = abs(Vel:x())+abs(Vel:y())
  394. if(Speed>30){
  395. soundVolume(1,Active*clamp(Speed/250,0.5,1))
  396. soundPitch(1,Active*clamp(Speed/2,25,100))
  397. }
  398. if(Speed<=150){Climb=1}
  399. if(Speed>150){Climb=0}
  400.  
  401. #if(changed(Climb)&Climb){for(I=1,Wheels:count()){if(Wheels[I,entity]){Wheels[I,entity]:setPhysProp("phx_tire_normal",1)}}}
  402. #if(changed(Climb)&!Climb){for(I=1,Wheels:count()){if(Wheels[I,entity]){Wheels[I,entity]:setPhysProp("rubber",1)}}}
  403.  
  404. #turret
  405. if(Play){
  406. soundVolume(2,1)
  407. soundPitch(2,100)
  408. }else{
  409. soundVolume(2,0)
  410. soundPitch(2,0)
  411. }
  412.  
  413. #if((changed(Gun:acfMagRounds())&!Gun:acfMagRounds())){Gun:soundPlay(3,0,ReloadSound)}else{soundStop(3,soundDuration(ReloadSound))}
  414. #if((changed(Gun2:acfMagRounds())&!Gun2:acfMagRounds())){Gun2:soundPlay(4,0,ReloadSound)}else{soundStop(4,soundDuration(ReloadSound))}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement