Advertisement
LGPvS

Untitled

May 8th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TNT bot
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Makes new tools that places a pixels with specified colors. If remove that pixel, all pixels in specified radius is will destroy.
  6. // @author LudwigOS
  7. // @match http://wire.ddns.net:9001/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function setPixel(x, y,rgb) {
  12. OWOP.world.setPixel(x, y, rgb);
  13. }
  14. function plotEllipseRect(x0, y0, x1, y1) {
  15. /* values of diameter */
  16. var a = Math.abs(x1 - x0);
  17. var b = Math.abs(y1 - y0);
  18. var b1 = b & 1;
  19.  
  20. /* error increment */
  21. var dx = 4 * (1 - a) * b * b;
  22. var dy = 4 * (b1 + 1) * a * a;
  23.  
  24. /* error of 1.step */
  25. var err = dx + dy + b1 * a * a;
  26. var e2;
  27.  
  28. if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */
  29. if (y0 > y1) { y0 = y1; } /* .. exchange them */
  30.  
  31. /* starting pixel */
  32. y0 += (b + 1) / 2;
  33. y1 = y0 - b1;
  34.  
  35. a *= 8 * a;
  36. b1 = 8 * b * b;
  37.  
  38. do {
  39. setPixel(x1, y0,[255,255,255]); /* I. Quadrant */
  40. setPixel(x0, y0,[255,255,255]); /* II. Quadrant */
  41. setPixel(x0, y1,[255,255,255]); /* III. Quadrant */
  42. setPixel(x1, y1,[255,255,255]); /* IV. Quadrant */
  43. e2 = 2 * err;
  44. if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
  45. if (e2 >= dx || 2 * err > dy) { x0++; x1--; err += dx += b1; } /* x step */
  46. } while (x0 <= x1);
  47.  
  48. while (y0 - y1 < b) { /* too early stop of flat ellipses a=1 */
  49. setPixel(x0 - 1, y0,[255,255,255]); /* -> finish tip of ellipse */
  50. setPixel(x1 + 1, y0++,[255,255,255]);
  51. setPixel(x0 - 1, y1,[255,255,255]);
  52. setPixel(x1 + 1, y1--,[255,255,255]);
  53. }
  54. }
  55.  
  56. setTimeout(function(){
  57. circleDraw=function(x2,y2,sizeCircle){ sizeCircle2=sizeCircle/8; plotEllipseRect(x2-sizeCircle2,y2-sizeCircle2,x2+sizeCircle2,y2+sizeCircle2);};
  58. explodeTNT = function(x3,y3,sizeExpl){explTNTI2=0; for(explTNTI=0;explTNTI<sizeExpl;explTNTI++){setTimeout(function(explTNTI){explTNTI2+=1; circleDraw(x3,y3,explTNTI2);},125*explTNTI);}};
  59.  
  60. normalTntColor=[255,0,0];
  61. getRandomArbitrary=function(min, max) { return Math.random() * (max - min) + min; };
  62.  
  63. tntData=[];
  64. tntDataInt=[];
  65.  
  66. c4DataInt=[];
  67.  
  68. uranDataInt=[];
  69. plutDataInt=[];
  70. uran2DataInt=[];
  71. placeTNT = function(x,y){ OWOP.world.setPixel(x,y,[255,0,0]); tntDataInt[x+", "+y]=setInterval(function(){tntData[x+", "+y]=OWOP.world.getPixel(x,y); if(tntData[x+", "+y]==undefined){tntData[x+", "+y]=OWOP.world.getPixel(x,y);} if(tntData[x+", "+y][0]<255,tntData[x+", "+y][1]>0,tntData[x+", "+y][2]>0){setTimeout(function(){explodeTNT(x+getRandomArbitrary(-4,4),y+getRandomArbitrary(-4,4),1); delete tntData[x+", "+y]; clearInterval(tntDataInt[x+", "+y]);},3000);}},-Infinity);};
  72. placeC4 = function(x,y){ OWOP.world.setPixel(x,y,[255,0,255]); c4DataInt[x+", "+y]=setInterval(function(){tntData[x+", "+y]=OWOP.world.getPixel(x,y); if(tntData[x+", "+y]==undefined){tntData[x+", "+y]=OWOP.world.getPixel(x,y);} if(tntData[x+", "+y][0]<255,tntData[x+", "+y][1]>0,tntData[x+", "+y][2]<255){setTimeout(function(){explodeTNT(x+getRandomArbitrary(-4,4),y+getRandomArbitrary(-4,4),2); delete tntData[x+", "+y]; clearInterval(c4DataInt[x+", "+y]);},3000);}},-Infinity);};
  73. placeUran = function(x,y){ OWOP.world.setPixel(x,y,[255,255,0]); uranDataInt[x+", "+y]=setInterval(function(){tntData[x+", "+y]=OWOP.world.getPixel(x,y); if(tntData[x+", "+y]==undefined){tntData[x+", "+y]=OWOP.world.getPixel(x,y);} if(tntData[x+", "+y][0]<255,tntData[x+", "+y][1]<255,tntData[x+", "+y][2]>0){setTimeout(function(){explodeTNT(x+getRandomArbitrary(-4,4),y+getRandomArbitrary(-4,4),4); delete tntData[x+", "+y]; clearInterval(uranDataInt[x+", "+y]);},3000);}},-Infinity);};
  74. placePlut = function(x,y){ OWOP.world.setPixel(x,y,[0,255,0]); plutDataInt[x+", "+y]=setInterval(function(){tntData[x+", "+y]=OWOP.world.getPixel(x,y); if(tntData[x+", "+y]==undefined){tntData[x+", "+y]=OWOP.world.getPixel(x,y);} if(tntData[x+", "+y][0]>0,tntData[x+", "+y][1]<255,tntData[x+", "+y][2]>0){setTimeout(function(){explodeTNT(x+getRandomArbitrary(-4,4),y+getRandomArbitrary(-4,4),5); delete tntData[x+", "+y]; clearInterval(plutDataInt[x+", "+y]);},3000);}},-Infinity);};
  75. placeUran2 = function(x,y){ OWOP.world.setPixel(x,y,[0,0,255]); uran2DataInt[x+", "+y]=setInterval(function(){tntData[x+", "+y]=OWOP.world.getPixel(x,y); if(tntData[x+", "+y]==undefined){tntData[x+", "+y]=OWOP.world.getPixel(x,y);} if(tntData[x+", "+y][0]>0,tntData[x+", "+y][1]>0,tntData[x+", "+y][2]<255){setTimeout(function(){explodeTNT(x+getRandomArbitrary(-4,4),y+getRandomArbitrary(-4,4),6); delete tntData[x+", "+y]; clearInterval(uran2DataInt[x+", "+y]);},3000);}},-Infinity);};
  76. OWOP.cursors.dynamite=OWOP.cursors.cursor;
  77. OWOP.cursors.c4=OWOP.cursors.cursor;
  78. OWOP.cursors.uran=OWOP.cursors.cursor;
  79.  
  80. OWOP.tool.addToolObject(new OWOP.tool.class('Dynamite', OWOP.cursors.dynamite, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
  81. tool.setEvent('mousedown mousemove', function (mouse, event) {
  82.  
  83. placeTNT(mouse.tileX,mouse.tileY);
  84. }
  85. );
  86.  
  87.  
  88. tool.setEvent('mouseup mousemove', function (mouse) {
  89. OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
  90. });
  91.  
  92. }));
  93. OWOP.tool.addToolObject(new OWOP.tool.class('C4', OWOP.cursors.c4, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
  94. tool.setEvent('mousedown mousemove', function (mouse, event) {
  95.  
  96. placeC4(mouse.tileX,mouse.tileY);
  97. }
  98. );
  99.  
  100.  
  101. tool.setEvent('mouseup mousemove', function (mouse) {
  102. OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
  103. });}));
  104. OWOP.tool.addToolObject(new OWOP.tool.class('Uran', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
  105. tool.setEvent('mousedown mousemove', function (mouse, event) {
  106.  
  107. placeUran(mouse.tileX,mouse.tileY);
  108. }
  109. );
  110.  
  111.  
  112. tool.setEvent('mouseup mousemove', function (mouse) {
  113. OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
  114. });}));
  115. OWOP.tool.addToolObject(new OWOP.tool.class('Plut', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
  116. tool.setEvent('mousedown mousemove', function (mouse, event) {
  117.  
  118. placePlut(mouse.tileX,mouse.tileY);
  119. }
  120. );
  121.  
  122.  
  123. tool.setEvent('mouseup mousemove', function (mouse) {
  124. OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
  125. });}));
  126. OWOP.tool.addToolObject(new OWOP.tool.class('Uran2', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
  127. tool.setEvent('mousedown mousemove', function (mouse, event) {
  128.  
  129. placeUran2(mouse.tileX,mouse.tileY);
  130. }
  131. );
  132.  
  133.  
  134. tool.setEvent('mouseup mousemove', function (mouse) {
  135. OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
  136. });}));
  137. },5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement