Diep Stack Bullets Script
Diep Stack Bullets Script
/*
How to use
How to run a script
Paste and run on console or install on Tampermonkey
Double shot
right click
Tank switching
Shift+T so Penta Shot, Spread Shot, Octo Tank Can be switched.(As for
the head tempo after switching, reload 7 premise)
Measurement of launch cycle
In the initial state, it shakes its neck at a tempo based on the
interval of continuous fire of reload 7. To change this tempo, measure the fire
interval as follows
1. Shift+M Set the launch speed measurement mode and measure the launch
speed for a while
2. Do not move the machine up, down, left or right while measuring.
Also, the measurement may go wrong if another man's shell flies near the aircraft.
3. When the variation of the average firing interval becomes smaller
again Shift+M Cancel measurement mode with
After measurement, shake your neck at a tempo based on the measured
firing interval.
+ Aim is fixed in the direction when pressing Shift + M on either side
during measurement. (So ??it is better to turn your back to the wall and press the
Shift + M key to keep the aircraft stationary)
+ Even if Reload 7 is considered to have poor accuracy, the accuracy
may increase if measured once
Toggle display / hide of text in upper left
I key
Repeated shooting function on / off switching
Shift+Q
*/
(function(){//info
if(window.updateInfo) return;
function toggle_info_container(e){
if(e.key == "i"){
info_container.style.display =
info_container.style.display=="block" ? "none" : "block";
}
}
window.addEventListener("keyup", toggle_info_container);
function MeasureCycle(){
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var real_arc = ctx.arc;
var real_setTransform = ctx.setTransform;
var a;
var tx = 0, ty = 0;
var a11 = 1;
var frameRequest;
var intervalEMA = null; // ms
function arc(){
real_arc.apply(ctx, arguments);
if(!found){
var aimX = window.innerWidth / 2 + 50 * direction;
var aimY = window.innerHeight / 2;
found = (tx - a11 < aimX) && (tx + a11 > aimX) && (ty - a11 <
aimY) && (ty + a11 > aimY);
}
}
function onFrame(_a){
frameRequest = window.requestAnimationFrame(onFrame);
a = _a;
if(!state && found){
if(inA){
var da = a - inA;
inA = a;
intervalEMA = intervalEMA ? 0.8 * intervalEMA + 0.2 * da :
da;
window.updateInfo && window.updateInfo(
"intervalEMA",
"??????: " + intervalEMA.toString().substr(0, 5) +
"ms"
);
}else{
inA = a;
}
}
state = found;
found = false;
}
function onMouseEvent(e){
e.stopPropagation();
}
this.start = function(_direction){
_direction = _direction || 1;
direction = _direction > 0 ? 1 : -1;
inA = null;
intervalEMA = null;
state = found = false;
ctx.setTransform = setTransform;
ctx.arc = arc;
this.terminate = function(){
ctx.setTransform = real_setTransform;
ctx.arc = real_arc;
(function(){
var cycleRate = 0.003125; // ms^-1
var maxAngle = Math.PI * 45 / 180;
var NCANNON = 3;
var angleUnit = maxAngle / (NCANNON - 1);
var tankData = [
{name: "Penta", cycleRate: 0.003125, maxAngle: Math.PI * 45 / 180,
NCANNON: 3},
{name: "SpreadShot", cycleRate: 0.001555, maxAngle: Math.PI * 75 / 180,
NCANNON: 6},
{name: "Octo", cycleRate: 0.003125, maxAngle: Math.PI * 45 / 180,
NCANNON: 2}
];
var tankIndex = 0;
var mouseX;
var mouseY;
var a = 0;
var startA = 0;
var artificialMouseMove = false;
function onMouseDown(e){
if(e.button == 2){
if(!effective){
startA = a - 50;
mouseX = e.clientX;
mouseY = e.clientY;
canvas.dispatchEvent(new MouseEvent("mousedown", {clientX:
mouseX, clientY: mouseY}));
}
effective = true;
}
}
function onMouseUp(e){
if(e.button == 2){
if(effective){
canvas.dispatchEvent(new MouseEvent("mouseup", {clientX:
mouseX, clientY: mouseY}));
}
effective = false;
}
}
function onMouseMove(e){
if(effective){
if(!artificialMouseMove){
e.stopPropagation();
mouseX = e.clientX;
mouseY = e.clientY;
}
}else{
mouseX = e.clientX;
mouseY = e.clientY;
}
}
function update(_a){
frameRequest = window.requestAnimationFrame(update);
a = _a;
if(effective){
var da = a - startA;
var state = Math.floor(cycleRate * da * NCANNON) % (NCANNON * 2);
var state1 = state % NCANNON;
var state2 = Math.floor(state / NCANNON);
var angle = angleUnit * state1 * (state1 % 2 == state2 ? 1 : -1);
var cx = window.innerWidth / 2;
var cy = window.innerHeight / 2;
var sin = Math.sin(angle);
var cos = Math.cos(angle);
artificialMouseMove = true;
canvas.dispatchEvent(new MouseEvent("mousemove", {clientX: x,
clientY: y}));
artificialMouseMove = false;
}
}
function onKeyUp(e){
if(e.key == "Q"){
disabled = !disabled;
if(disabled){
if(measuring){
cycleRate = 1 / measure.terminate();
measuring = false;
} else stop();
}else start();
window.updateInfo && window.updateInfo("off", disabled ? "????" :
null);
return;
}
if(disabled) return;
if(e.key == "M"){
if(measuring){
cycleRate = 1 / measure.terminate();
start();
measuring = false;
}else{
stop();
measure.start(mouseX - window.innerWidth / 2);
measuring = true;
}
}else if(e.key == "T"){
changeTank((tankIndex + 1) % tankData.length);
}
}
function changeTank(index){
var data = tankData[index];
tankIndex = index;
function init(){
window.addEventListener("keyup", onKeyUp);
start();
changeTank(0);
}
function start(){
canvas.addEventListener("mousedown", onMouseDown);
canvas.addEventListener("mouseup", onMouseUp);
window.addEventListener("mousemove", onMouseMove, true);
frameRequest = window.requestAnimationFrame(update);
}
function stop(){
canvas.removeEventListener("mousedown", onMouseDown);
canvas.removeEventListener("mouseup", onMouseUp);
window.removeEventListener("mousemove", onMouseMove, true);
window.cancelAnimationFrame(frameRequest);
effective = false;
}
init();
})();v