Greasy Fork

Greasy Fork is available in English.

Zones Only

made with much love

当前为 2021-10-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Zones Only
// @description  made with much love
// @version      0.0.1
// @author       Cazka#1820
// @match        *://diep.io/*
// @grant        none
// @require      http://greasyfork.icu/scripts/433681-diepapi/code/diepAPI.js?version=977858
// @namespace http://greasyfork.icu/users/541070
// ==/UserScript==
'use strict';

function drawZones() {
    ctx.save();

    ctx.globalAlpha = 0.08;

    if (localStorage.gamemode === '4teams') {
        let center;
        let radius;

        //blue
        center = arenaScaling.toScreenPos(new Vector(-11150 + 1675, -11150 + 1675));
        radius = arenaScaling.toScreenPos(new Vector(-11150 + 1675, -11150 + 1675 + 5250)).y - center.y;
        ctx.fillStyle = '#006480';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();
        radius = arenaScaling.toScreenPos(new Vector(-11150 + 1675, -11150 + 1675 + 3800)).y - center.y;
        ctx.fillStyle = '#ff6480';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();

        //purple
        center = arenaScaling.toScreenPos(new Vector(11150 - 1675, -11150 + 1675));
        radius = arenaScaling.toScreenPos(new Vector(11150 - 1675, -11150 + 1675 + 5250)).y - center.y;
        ctx.fillStyle = '#644280';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();
        radius = arenaScaling.toScreenPos(new Vector(-11150 + 1675, -11150 + 1675 + 3800)).y - center.y;
        ctx.fillStyle = '#ff4280';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();

        //green
        center = arenaScaling.toScreenPos(new Vector(-11150 + 1675, 11150 - 1675));
        radius = arenaScaling.toScreenPos(new Vector(-11150 + 1675, 11150 - 1675 + 5250)).y - center.y;
        ctx.fillStyle = '#00803e';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();
        radius = arenaScaling.toScreenPos(new Vector(-11150 + 1675, 11150 - 1675 + 3800)).y - center.y;
        ctx.fillStyle = '#ff803e';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();

        //red
        center = arenaScaling.toScreenPos(new Vector(11150 - 1675, 11150 - 1675));
        radius = arenaScaling.toScreenPos(new Vector(11150 - 1675, 11150 - 1675 + 5250)).y - center.y;
        ctx.fillStyle = '#963033';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();
        radius = arenaScaling.toScreenPos(new Vector(11150 - 1675, 11150 - 1675 + 3800)).y - center.y;
        ctx.fillStyle = '#ff3033';
        ctx.beginPath();
        ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        ctx.fill();
    } else if (localStorage.gamemode === 'teams') {
        let coords1;
        let coords2;

        //blue
        coords1 = arenaScaling.toScreenPos(new Vector(-11150, -11150));
        coords2 = arenaScaling.toScreenPos(new Vector(-11150 + 5500, 11150));
        ctx.fillStyle = '#006480';
        ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
        coords2 = arenaScaling.toScreenPos(new Vector(-11150 + 4150, 11150));
        ctx.fillStyle = '#ff6480';
        ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);

        //red
        coords1 = arenaScaling.toScreenPos(new Vector(11150, -11150));
        coords2 = arenaScaling.toScreenPos(new Vector(11150 - 5500, 11150));
        ctx.fillStyle = '#963033';
        ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
        coords2 = arenaScaling.toScreenPos(new Vector(11150 - 4150, 11150));
        ctx.fillStyle = '#ff3033';
        ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
    }
    //pentagon nest
    let coords1;
    let coords2;

    coords1 = arenaScaling.toScreenPos(new Vector(-1115, -1115));
    coords2 = arenaScaling.toScreenPos(new Vector(1115, 1115));
    ctx.fillStyle = '#8aff69';
    ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);

    ctx.restore();
}

const { Vector, arenaScaling, player, game } = window.diepAPI;
const ctx = document.getElementById('canvas').getContext('2d');
let isAlive = false;

player.on('dead', () => (isAlive = false));
player.on('spawn', () => (isAlive = true));


game.once('ready', () => {
    game.on('frame', () => {
        if(isAlive) drawZones();
    });
});