Camera mover
当前为
// ==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;
}
});