TankTrouble Booster

Boost performance for better game experience.

  1. // ==UserScript==
  2. // @name TankTrouble Booster
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.1.3
  5. // @license GPL-3.0
  6. // @description Boost performance for better game experience.
  7. // @author kamarov
  8. // @match https://tanktrouble.com/*
  9. // @run-at document-end
  10. // @grant GM_addStyle
  11. // @require https://update.greasyfork.org/scripts/482092/1297984/TankTrouble%20Development%20Library.js
  12. // ==/UserScript==
  13.  
  14. //Disable camera shake
  15. UIConstants.MAX_CAMERA_SHAKE = 0;
  16. UIConstants.CAMERA_SHAKE_FADE = 0;
  17. UIConstants.MINE_EXPLOSION_CAMERA_SHAKE = 0;
  18.  
  19. //Disable feather particles spawning
  20. UIConstants.TANK_FEATHER_COUNT = 0;
  21. UIConstants.TANK_FEATHER_POOL_SIZE = 0;
  22.  
  23. //Disable score fragments particles spawning
  24. UIConstants.MAX_SCORE_FRAGMENTS_PER_EXPLOSION = 0;
  25. UIConstants.MIN_SCORE_FRAGMENTS_PER_LETTER = 0;
  26.  
  27. //Lower the sparkle effects
  28. UIConstants.GOLD_SPARKLE_MAX_INTERVAL_TIME = 9999
  29. UIConstants.GOLD_SPARKLE_MIN_INTERVAL_TIME = 9999
  30. UIConstants.DIAMOND_SPARKLE_MAX_INTERVAL_TIME = 9999
  31. UIConstants.DIAMOND_SPARKLE_MIN_INTERVAL_TIME = 9999
  32.  
  33. //Lower and disable garage animations
  34. UIConstants.GARAGE_WELD_PARTICLE_TIME = 500
  35. UIConstants.GARAGE_WELD_SMOKE_TIME = 500
  36. UIConstants.GARAGE_WELD_SPARK_TIME = 500
  37. UIConstants.GARAGE_SPRAY_SHAKE_PROBABILITY = 0
  38. UIConstants.GARAGE_SPRAY_PARTICLE_TIME = 550
  39.  
  40. //Disable rubble particles
  41. UIConstants.RUBBLE_TREAD_OFFSET = 0
  42. UIConstants.RUBBLE_FRAGMENT_POOL_SIZE = 0
  43. UIConstants.RUBBLE_FRAGMENT_MAX_LIFETIME= 0
  44. UIConstants.RUBBLE_FRAGMENT_MIN_LIFETIME= 0
  45. UIConstants.RUBBLE_FRAGMENT_MAX_ROTATION_SPEED= 0
  46. UIConstants.RUBBLE_FRAGMENT_SPEED_SCALE = 0
  47. UIConstants.RUBBLE_FRAGMENT_RANDOM_SPEED = 0
  48. UIConstants.RUBBLE_SMOKE_SPEED_SCALE = 0
  49. UIConstants.RUBBLE_SMOKE_RANDOM_SPEED = 0
  50. UIConstants.INVERSE_RUBBLE_SPAWN_PROBABILITY_IN_COLLISION = 9999
  51. UIConstants.INVERSE_RUBBLE_SPAWN_PROBABILITY_IN_THE_OPEN = 9999
  52.  
  53. //Lower and disable shield animations
  54. UIConstants.SHIELD_LAYER_1_ROTATION_SPEED = 0
  55. UIConstants.SHIELD_LAYER_2_ROTATION_SPEED = 0
  56. UIConstants.SHIELD_NUM_BOLTS = 0
  57. UIConstants.SHIELD_SPARK_BOLT_POOL_SIZE = 0
  58.  
  59. //Disable poof effects weapons
  60. UIConstants.BULLET_PUFF_POOL_SIZE = 0
  61.  
  62. //Lower the amount of particles spawning for each quality
  63. QualityManager.QUALITY_VALUES.auto = {
  64. "tank explosion smoke count": 2,
  65. "tank explosion fragment count": 2,
  66. "missile launch smoke count": 0,
  67. "missile smoke frequency": 9999,
  68. "mine explosion smoke count": 2,
  69. "crate land dust count": 0,
  70. "aimer min segment length":2,
  71. "aimer off max segment length": 15.0,
  72. "aimer on max segment length": 6.0,
  73. "bullet puff count": 0,
  74. "shield inverse bolt probability": 1,
  75. "shield spark particles per emit": 0,
  76. "spawn zone inverse unstable particle probability": 1,
  77. "spawn zone num collapse particles": 0
  78. };
  79.  
  80. QualityManager.QUALITY_VALUES.high = {
  81. "tank explosion smoke count": 2,
  82. "tank explosion fragment count": 2,
  83. "missile launch smoke count": 0,
  84. "missile smoke frequency": 9999,
  85. "mine explosion smoke count": 2,
  86. "crate land dust count": 0,
  87. "aimer min segment length": 2,
  88. "aimer off max segment length": 10.0,
  89. "aimer on max segment length": 5.0,
  90. "bullet puff count": 0,
  91. "shield inverse bolt probability": 1,
  92. "shield spark particles per emit": 0,
  93. "spawn zone inverse unstable particle probability": 1,
  94. "spawn zone num collapse particles": 0
  95. };
  96.  
  97. QualityManager.QUALITY_VALUES.low = {
  98. "tank explosion smoke count": 1,
  99. "tank explosion fragment count": 1,
  100. "missile launch smoke count": 0,
  101. "missile smoke frequency": 9999,
  102. "mine explosion smoke count": 1,
  103. "crate land dust count": 0,
  104. "aimer min segment length": 0,
  105. "aimer off max segment length": 12.0,
  106. "aimer on max segment length": 6.0,
  107. "bullet puff count": 0,
  108. "shield inverse bolt probability": 1,
  109. "shield spark particles per emit": 0,
  110. "spawn zone inverse unstable particle probability": 1,
  111. "spawn zone num collapse particles": 0
  112. };
  113.  
  114. whenContentInitialized().then(() => {
  115. Game.UIBootState.method('create', function () {
  116. this.log = Log.create('UIBootState');
  117.  
  118. // Input & scale settings
  119. this.input.touch.preventDefault = false;
  120. this.scale.compatibility.scrollTo = false;
  121.  
  122. // Disable right-click context menu
  123. this.game.canvas.oncontextmenu = function (e) {
  124. e.preventDefault();
  125. };
  126.  
  127. // Prevent game from pausing when tab loses focus
  128. this.game.stage.disableVisibilityChange = true;
  129.  
  130. // Add key capture for common keys
  131. this.input.keyboard.addKeyCapture([
  132. Phaser.Keyboard.LEFT,
  133. Phaser.Keyboard.RIGHT,
  134. Phaser.Keyboard.UP,
  135. Phaser.Keyboard.DOWN,
  136. Phaser.Keyboard.SPACEBAR
  137. ]);
  138.  
  139. // Disable input if overlay is showing
  140. if (OverlayManager.isOverlayShowing()) {
  141. this.input.enabled = false;
  142. }
  143.  
  144. // Set world bounds and background
  145. this.world.bounds = new Phaser.Rectangle(0, 0, this.game.width, this.game.height);
  146. this.camera.setBoundsToWorld();
  147. this.stage.backgroundColor = '#fff';
  148.  
  149. // Change animation frames
  150. var time = this.game.time;
  151. time.physicsElapsed = 1 / 120;
  152. time.physicsElapsedMS = 1000 * time.physicsElapsed;
  153.  
  154. // Handle high DPI scaling
  155. if (this.game.device.pixelRatio > 1) {
  156. this.scale.scaleMode = Phaser.ScaleManager.USER_SCALE;
  157.  
  158. // Scale down for high DPI
  159. const scaleRatio = 1 / this.game.device.pixelRatio;
  160. this.scale.setUserScale(scaleRatio, scaleRatio, 0, 0);
  161. this.scale.setGameSize(
  162. this.game.width * this.game.device.pixelRatio,
  163. this.game.height * this.game.device.pixelRatio
  164. );
  165.  
  166. // Handle resizing
  167. this.scale.setResizeCallback(function (scale, parentBounds) {
  168. const newWidth = parentBounds.width * this.game.device.pixelRatio;
  169. const newHeight = parentBounds.height * this.game.device.pixelRatio;
  170.  
  171. if (
  172. Math.abs(newWidth - this.game.width) >= 0.01 ||
  173. Math.abs(newHeight - this.game.height) >= 0.01
  174. ) {
  175. this.log.debug('RESIZE CANVAS!');
  176. this.scale.setGameSize(newWidth, newHeight);
  177. }
  178. }, this);
  179. } else {
  180. this.scale.scaleMode = Phaser.ScaleManager.RESIZE;
  181. }
  182.  
  183. // Start preload state
  184. this.state.start('Preload');
  185. });
  186.  
  187. //Uncap FPS
  188. (function() {
  189. 'use strict';
  190.  
  191. const originalRequestAnimationFrame = window.requestAnimationFrame;
  192.  
  193. window.requestAnimationFrame = function(callback) {
  194. return originalRequestAnimationFrame(function(timestamp) {
  195. setTimeout(() => callback(performance.now()), 0);
  196. });
  197. };
  198.  
  199. if ('requestAnimationFrame' in window) {
  200. console.log('FPS uncapped.');
  201. }
  202. })();
  203.  
  204. })