Base Zones

made with much love

  1. // ==UserScript==
  2. // @name Base Zones
  3. // @description made with much love
  4. // @version 0.0.10
  5. // @author Cazka#1820
  6. // @match *://diep.io/*
  7. // @grant none
  8. // @require https://greasyfork.org/scripts/433681-diepapi/code/diepAPI.js?version=1117485
  9. // @namespace https://greasyfork.org/users/541070
  10. // ==/UserScript==
  11. 'use strict';
  12. const { Vector } = window.diepAPI.core;
  13. const { scaling, player, game } = window.diepAPI.apis;
  14.  
  15. const { backgroundOverlay } = window.diepAPI.tools;
  16. const ctx = backgroundOverlay.ctx;
  17.  
  18. // Bases (width = 67 * 50)
  19. const blue_base = new Vector(-11150 + 1675, -11150 + 1675);
  20. const purple_base = new Vector(11150 - 1675, -11150 + 1675);
  21. const green_base = new Vector(-11150 + 1675, 11150 - 1675);
  22. const red_base = new Vector(11150 - 1675, 11150 - 1675);
  23.  
  24. // Base Drones
  25. const danger_radius = new Vector(5250, 0);
  26. const attack_radius = new Vector(3800, 0);
  27.  
  28. function drawZones() {
  29. ctx.save();
  30.  
  31. ctx.globalAlpha = 0.08;
  32.  
  33. if (player.gamemode === '4teams') {
  34. let center;
  35. const radius1 = scaling.toCanvasUnits(danger_radius).x;
  36. const radius2 = scaling.toCanvasUnits(attack_radius).x;
  37.  
  38. //blue
  39. center = scaling.toCanvasPos(blue_base);
  40. ctx.fillStyle = '#006480';
  41. ctx.beginPath();
  42. ctx.arc(center.x, center.y, radius1, 0, 2 * Math.PI);
  43. ctx.fill();
  44. ctx.fillStyle = '#ff6480';
  45. ctx.beginPath();
  46. ctx.arc(center.x, center.y, radius2, 0, 2 * Math.PI);
  47. ctx.fill();
  48.  
  49. //purple
  50. center = scaling.toCanvasPos(purple_base);
  51. ctx.fillStyle = '#644280';
  52. ctx.beginPath();
  53. ctx.arc(center.x, center.y, radius1, 0, 2 * Math.PI);
  54. ctx.fill();
  55. ctx.fillStyle = '#ff4280';
  56. ctx.beginPath();
  57. ctx.arc(center.x, center.y, radius2, 0, 2 * Math.PI);
  58. ctx.fill();
  59.  
  60. //green
  61. center = scaling.toCanvasPos(green_base);
  62. ctx.fillStyle = '#00803e';
  63. ctx.beginPath();
  64. ctx.arc(center.x, center.y, radius1, 0, 2 * Math.PI);
  65. ctx.fill();
  66. ctx.fillStyle = '#ff803e';
  67. ctx.beginPath();
  68. ctx.arc(center.x, center.y, radius2, 0, 2 * Math.PI);
  69. ctx.fill();
  70.  
  71. //red
  72. center = scaling.toCanvasPos(red_base);
  73. ctx.fillStyle = '#963033';
  74. ctx.beginPath();
  75. ctx.arc(center.x, center.y, radius1, 0, 2 * Math.PI);
  76. ctx.fill();
  77. ctx.fillStyle = '#ff3033';
  78. ctx.beginPath();
  79. ctx.arc(center.x, center.y, radius2, 0, 2 * Math.PI);
  80. ctx.fill();
  81. } else if (player.gamemode === 'teams') {
  82. let coords1;
  83. let coords2;
  84.  
  85. //blue
  86. coords1 = scaling.toCanvasPos(new Vector(-11150, -11150));
  87. coords2 = scaling.toCanvasPos(new Vector(-11150 + 5500, 11150));
  88. ctx.fillStyle = '#006480';
  89. ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
  90. coords2 = scaling.toCanvasPos(new Vector(-11150 + 4150, 11150));
  91. ctx.fillStyle = '#ff6480';
  92. ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
  93.  
  94. //red
  95. coords1 = scaling.toCanvasPos(new Vector(11150, -11150));
  96. coords2 = scaling.toCanvasPos(new Vector(11150 - 5500, 11150));
  97. ctx.fillStyle = '#963033';
  98. ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
  99. coords2 = scaling.toCanvasPos(new Vector(11150 - 4150, 11150));
  100. ctx.fillStyle = '#ff3033';
  101. ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
  102. }
  103. //pentagon nest
  104. let coords1;
  105. let coords2;
  106.  
  107. coords1 = scaling.toCanvasPos(new Vector(-1115, -1115));
  108. coords2 = scaling.toCanvasPos(new Vector(1115, 1115));
  109. ctx.fillStyle = '#8aff69';
  110. ctx.fillRect(coords1.x, coords1.y, coords2.x - coords1.x, coords2.y - coords1.y);
  111.  
  112. ctx.restore();
  113. }
  114.  
  115. game.once('ready', () => {
  116. game.on('frame', () => {
  117. drawZones();
  118. });
  119. });