Camera Tool

Camera mover

目前为 2022-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Camera Tool
  3. // @version 1.0.0
  4. // @author Shaunxx & AA1134
  5. // @description Camera mover
  6. // @match https://bonk.io/gameframe-release.html
  7. // @run-at document-start
  8. // @grant none
  9. // @license GPL-3.0
  10. // @namespace https://greasyfork.org/en/users/911845
  11. // ==/UserScript==
  12.  
  13. const injectorName = `Camera`;
  14. const errorMsg = `Whoops! ${injectorName} was unable to load.
  15. This may be due to an update to Bonk.io. If so, please report this error!
  16. This could also be because you have an extension that is incompatible with \
  17. ${injectorName}`;
  18.  
  19. function injector(src){
  20. let newSrc = src;
  21. // replaces screen shake with camera pan
  22. let screenshake = `if(L1Q.shk && (L1Q.shk.x != 0 || L1Q.shk.y != 0)){this.shakeTweenGroup.removeAll();var p1Q=new TWEEN.Tween(this.shakeTweenObject,this.shakeTweenGroup);var Y1Q=50;var C1Q=800;p1Q.to({x:L1Q.shk.x,y:L1Q.shk.y},Y1Q);p1Q.easing(TWEEN.Easing.Cubic.Out);p1Q.onComplete(()=>{var m1Q=new TWEEN.Tween(this.shakeTweenObject,this.shakeTweenGroup);m1Q.to({x:0,y:0},C1Q);m1Q.easing(TWEEN.Easing.Elastic.Out);G9b.g9b();m1Q.start();});p1Q.start();}`
  23. newSrc = newSrc.replace(screenshake, `this.particleManager.render(f1Q, L1Q, S1Q, this.renderer, this.isReplay);
  24. var keys = {}
  25. var n = 15
  26. function handleKeyPress(evt) {
  27. let { keyCode, type } = evt || Event;
  28. let isKeyDown = (type == 'keydown');
  29. keys[keyCode] = isKeyDown;
  30. if (!locked) {
  31. locked = true;
  32. setTimeout(unlock, 0);
  33. if (isKeyDown && keys[104]) { // NUMPAD_UP
  34. if (keys[100]) { moveTwo(n, n); } // NUMPAD_LEFT
  35. else if (keys[102]) { moveTwo(-n, n); } // MUMPAD_RIGHT
  36. else { cameraY += n; }
  37. }else if (isKeyDown && keys[98]) { // NUMPAD_DOWN
  38. if (keys[100]) { moveTwo(n, -n); } // NUMPAD_LEFT
  39. else if (keys[102]) { moveTwo(-n, -n); } // NUMPAD_RIGHT
  40. else { cameraY -= n; }
  41. }else if (isKeyDown && keys[100]) { cameraX += n; } // NUMPAD_LEFT
  42. else if (isKeyDown && keys[102]) { cameraX -= n; } // NUMPAD_RIGHT
  43. else if (isKeyDown && keys[101]) { resetCamera() } // NUMPAD_CENTER
  44. moveCamera();
  45. }
  46. };
  47.  
  48. function unlock () {
  49. locked = false;
  50. }
  51.  
  52. function moveTwo(x, y) {
  53. cameraX += x
  54. cameraY += y
  55. }
  56.  
  57. window.addEventListener("keyup", handleKeyPress);
  58. window.addEventListener("keydown", handleKeyPress);
  59.  
  60. function resetCamera() {
  61. cameraX = 0;
  62. cameraY = 0;
  63. }
  64.  
  65. var test1 = this.shakeTweenObject
  66. var test2 = this.shakeTweenGroup
  67. function moveCamera() {
  68. console.log("movin")
  69. test2.removeAll();
  70. var p1Q = new TWEEN.Tween(test1, test2);
  71. p1Q.to({
  72. x: cameraX,
  73. y: cameraY
  74. }, 0);
  75. p1Q.easing(TWEEN.Easing.Cubic.Out);
  76. p1Q.start();
  77. }`)
  78.  
  79. newSrc = newSrc.replace("I8yy[443628]=(function(){", `I8yy[443628] = (function() {
  80. cameraX = 0
  81. cameraY = 0
  82. locked = false;`)
  83.  
  84. if(src === newSrc) throw "Injection failed!";
  85. console.log(injectorName+" injector run");
  86. return newSrc;
  87. }
  88.  
  89. // Compatibility with Excigma's code injector userscript
  90. if(!window.bonkCodeInjectors) window.bonkCodeInjectors = [];
  91. window.bonkCodeInjectors.push(bonkCode => {
  92. try {
  93. return injector(bonkCode);
  94. } catch (error) {
  95. alert(errorMsg);
  96. throw error;
  97. }
  98. });