Camera Tool

Camera mover

目前為 2022-05-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Camera Tool
// @version      1.0.0
// @author       Shaunxx & AA1134
// @description  Camera mover
// @match        https://bonk.io/gameframe-release.html
// @run-at       document-start
// @grant        none
// @license      GPL-3.0
// @namespace    https://greasyfork.org/en/users/911845
// ==/UserScript==

const injectorName = `Camera`;
const errorMsg = `Whoops! ${injectorName} was unable to load.
This may be due to an update to Bonk.io. If so, please report this error!
This could also be because you have an extension that is incompatible with \
${injectorName}`;

function injector(src){
  let newSrc = src;
  // replaces screen shake with camera pan
  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();}`
  newSrc = newSrc.replace(screenshake, `this.particleManager.render(f1Q, L1Q, S1Q, this.renderer, this.isReplay);
                var keys = {}
                var n = 15
                function handleKeyPress(evt) {
                    let { keyCode, type } = evt || Event;
                    let isKeyDown = (type == 'keydown');
                    keys[keyCode] = isKeyDown;
                    if (!locked) {
                        locked = true;
                        setTimeout(unlock, 0);
                        if (isKeyDown && keys[104])       {                     // NUMPAD_UP
                            if (keys[100])                { moveTwo(n, n);   }  // NUMPAD_LEFT
                            else if (keys[102])           { moveTwo(-n, n);  }  // MUMPAD_RIGHT
                            else                          { cameraY += n;    }
                        }else if (isKeyDown && keys[98])  {                     // NUMPAD_DOWN
                            if (keys[100])                { moveTwo(n, -n);  }  // NUMPAD_LEFT
                            else if (keys[102])           { moveTwo(-n, -n); }  // NUMPAD_RIGHT
                            else                          { cameraY -= n;    }
                        }else if (isKeyDown && keys[100]) { cameraX += n;    }  // NUMPAD_LEFT
                        else if (isKeyDown && keys[102])  { cameraX -= n;    }  // NUMPAD_RIGHT
                        else if (isKeyDown && keys[101])  { resetCamera()    }  // NUMPAD_CENTER
                        moveCamera();
                    }
                };

                function unlock () {
                    locked = false;
                }

                function moveTwo(x, y) {
                    cameraX += x
                    cameraY += y
                }

                window.addEventListener("keyup", handleKeyPress);
                window.addEventListener("keydown", handleKeyPress);

                function resetCamera() {
                    cameraX = 0;
                    cameraY = 0;
                }

                var test1 = this.shakeTweenObject
                var test2 = this.shakeTweenGroup
                function moveCamera() {
                    console.log("movin")
                    test2.removeAll();
                    var p1Q = new TWEEN.Tween(test1, test2);
                    p1Q.to({
                        x: cameraX,
                        y: cameraY
                    }, 0);
                    p1Q.easing(TWEEN.Easing.Cubic.Out);
                    p1Q.start();
                }`)

   newSrc = newSrc.replace("I8yy[443628]=(function(){", `I8yy[443628] = (function() {
    cameraX = 0
    cameraY = 0
    locked = false;`)

  if(src === newSrc) throw "Injection failed!";
  console.log(injectorName+" injector run");
  return newSrc;
}

// Compatibility with Excigma's code injector userscript
if(!window.bonkCodeInjectors) window.bonkCodeInjectors = [];
window.bonkCodeInjectors.push(bonkCode => {
	try {
		return injector(bonkCode);
	} catch (error) {
		alert(errorMsg);
		throw error;
	}
});