Predator And Hunter Stack (Any reload)

press the buttons to stack predator and hunter and increase and decrease reload

当前为 2023-12-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Predator And Hunter Stack (Any reload)
// @namespace    http://tampermonkey.net/
// @version      1
// @description  press the buttons to stack predator and hunter and increase and decrease reload
// @author       MI300#4401
// @match        https://diep.io/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      dont copy
// ==/UserScript==
let isPredator = true;
function shoot(w) {
  input.key_down(1);
  setTimeout (() => {
    input.key_up(1);
  },w);
}

let reload = 7;
const predator = [
  [50, 600, 1400, 2800], // 0 reload
  [50, 600, 1300, 2700], // 1 reload
  [50, 600, 1200, 2450], // 2 reload
  [50, 300, 1100, 2200], // 3 reload
  [50, 300, 1000, 2100], // 4 reload
  [50, 300, 900, 1800], // 5 reload
  [50, 300, 800, 1700], // 6 reload
  [50, 300, 750, 1500], // 7 reload
]
const hunter = [
  [50, 1200], // 0 reload
  [50, 1100], // 1 reload
  [50, 1000], // 2 reload
  [50, 950], // 3 reload
  [50, 800], // 4 reload
  [50, 725], // 5 reload
  [50, 700], // 6 reload
  [50, 625], // 7 reload
]

function clump() {
  console.log('stacking predator')
  shoot(predator[reload][0]);
  setTimeout(() => {
    shoot(predator[reload][1]);
  },predator[reload][2]);
  setTimeout(() => {
    input.key_down (69);
    input.key_up (69);
  },predator[reload][3]);
}
function clump2(){
  console.log('stacking hunter')
  shoot(hunter[reload][0])
  setTimeout(() => {
    input.key_down (69);
    input.key_up (69);
  },hunter[reload][1])
}

function increaseReload(){
  console.log('increased reload')
  if(reload != 7){
    reload++;
  }
}
function decreaseReload(){
  console.log('decreased reload')
  if(reload != 0){
    reload--;
  }
}

document.addEventListener ('keydown', e => {
  if(!input.should_prevent_unload()){
    return;
  }
  if(e.key === '[') clump();
  if(e.key === ']') clump2()
});

// gui
setTimeout(function(){
  const canvas = document.getElementById("canvas");
  const context = canvas.getContext("2d");
  const themes = [
    // dark      // light
    ['#75ba50', '#aeff82'], // green
    ['#2a25fa', '#7d7afa'], // blue
    ['#c92233', '#fa6b77'], // red
    ['#9a9c43', '#def58c'], // yellow
  ]
  let buttons = [];
  let hover = [];

  function render(){
    window.requestAnimationFrame(render)
    handleMouse()

    buttons.forEach(button => {
      let text = button.text;
      context.beginPath()
      context.strokeStyle = '#4d4c4c'
      context.fillStyle = button.style[0]
      context.lineWidth = 5;
      context.rect(button.x, button.y, button.width, button.height)
      context.fillRect(button.x, button.y + button.height / 2, button.width, button.height / 2)
      context.fillStyle = button.style[1]
      context.fillRect(button.x, button.y, button.width, button.height / 2)
      context.stroke();

      context.font = "20px arial";
      context.strokeStyle = '#000000';
      context.fillStyle = '#FFFFFF';

      console.log(button.style)
      if(button.id == 2 || button.id == 3){
        text = reload + button.text;
      }
      context.strokeText(text, button.x + 5, button.y + button.height - 8)
      context.fillText(text, button.x + 5, button.y + button.height - 8)
    });
  }

  function handleMouse(){
    let d = false;
    hover.forEach(h => {
      if(h){
        canvas.style.cursor = "pointer"
        d = true;
      }
    });
    if(!d){
      canvas.style.cursor = "auto";
    }
  }

  function createButton(x, y, width, height, text, id, callback){
    buttons.push(
      {
        x: x,
        y: y,
        width: width,
        height: height,
        text: text,
        style: themes[id],
        id: id,
      }
    )
    const offsetX = /*1.25*/ 0.8;
    const offsetY = /*1.25*/ 0.8;
    const rx = x * offsetX;
    const ry = y * offsetY;
    const rw = width * offsetX;
    const rh = height * offsetY;

    canvas.addEventListener('mousedown', function(e) {
      if(e.x > rx && e.x < rx + rw && e.y > ry && e.y < ry + rh){
        callback()
      }
    })
    canvas.addEventListener('mousemove', function(e) {
      if(e.x > rx && e.x < rx + rw && e.y > ry && e.y < ry + rh){
        hover[id] = true;
      }else{
        hover[id] = false;
      }
    })
  }
  createButton(450, 20, 100, 35, "Predator", 0, clump)
  createButton(570, 20, 100, 35, "Hunter", 1, clump2)
  createButton(690, 20, 50, 35, "-", 2, decreaseReload)
  createButton(760, 20, 50, 35, "+", 3, increaseReload)

  window.requestAnimationFrame(render)
}, 2500)