Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TNT bot
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Makes new tools that places a pixels with specified colors. If remove that pixel, all pixels in specified radius is will destroy.
- // @author LudwigOS
- // @match http://wire.ddns.net:9001/*
- // @grant none
- // ==/UserScript==
- function setPixel(x, y,rgb) {
- OWOP.world.setPixel(x, y, rgb);
- }
- function plotEllipseRect(x0, y0, x1, y1) {
- /* values of diameter */
- var a = Math.abs(x1 - x0);
- var b = Math.abs(y1 - y0);
- var b1 = b & 1;
- /* error increment */
- var dx = 4 * (1 - a) * b * b;
- var dy = 4 * (b1 + 1) * a * a;
- /* error of 1.step */
- var err = dx + dy + b1 * a * a;
- var e2;
- if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */
- if (y0 > y1) { y0 = y1; } /* .. exchange them */
- /* starting pixel */
- y0 += (b + 1) / 2;
- y1 = y0 - b1;
- a *= 8 * a;
- b1 = 8 * b * b;
- do {
- setPixel(x1, y0,[255,255,255]); /* I. Quadrant */
- setPixel(x0, y0,[255,255,255]); /* II. Quadrant */
- setPixel(x0, y1,[255,255,255]); /* III. Quadrant */
- setPixel(x1, y1,[255,255,255]); /* IV. Quadrant */
- e2 = 2 * err;
- if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
- if (e2 >= dx || 2 * err > dy) { x0++; x1--; err += dx += b1; } /* x step */
- } while (x0 <= x1);
- while (y0 - y1 < b) { /* too early stop of flat ellipses a=1 */
- setPixel(x0 - 1, y0,[255,255,255]); /* -> finish tip of ellipse */
- setPixel(x1 + 1, y0++,[255,255,255]);
- setPixel(x0 - 1, y1,[255,255,255]);
- setPixel(x1 + 1, y1--,[255,255,255]);
- }
- }
- setTimeout(function(){
- circleDraw=function(x2,y2,sizeCircle){ sizeCircle2=sizeCircle/8; plotEllipseRect(x2-sizeCircle2,y2-sizeCircle2,x2+sizeCircle2,y2+sizeCircle2);};
- explodeTNT = function(x3,y3,sizeExpl){explTNTI2=0; for(explTNTI=0;explTNTI<sizeExpl;explTNTI++){setTimeout(function(explTNTI){explTNTI2+=1; circleDraw(x3,y3,explTNTI2);},125*explTNTI);}};
- normalTntColor=[255,0,0];
- getRandomArbitrary=function(min, max) { return Math.random() * (max - min) + min; };
- tntData=[];
- tntDataInt=[];
- c4DataInt=[];
- uranDataInt=[];
- plutDataInt=[];
- uran2DataInt=[];
- 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);};
- 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);};
- 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);};
- 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);};
- 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);};
- OWOP.cursors.dynamite=OWOP.cursors.cursor;
- OWOP.cursors.c4=OWOP.cursors.cursor;
- OWOP.cursors.uran=OWOP.cursors.cursor;
- OWOP.tool.addToolObject(new OWOP.tool.class('Dynamite', OWOP.cursors.dynamite, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
- tool.setEvent('mousedown mousemove', function (mouse, event) {
- placeTNT(mouse.tileX,mouse.tileY);
- }
- );
- tool.setEvent('mouseup mousemove', function (mouse) {
- OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
- });
- }));
- OWOP.tool.addToolObject(new OWOP.tool.class('C4', OWOP.cursors.c4, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
- tool.setEvent('mousedown mousemove', function (mouse, event) {
- placeC4(mouse.tileX,mouse.tileY);
- }
- );
- tool.setEvent('mouseup mousemove', function (mouse) {
- OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
- });}));
- OWOP.tool.addToolObject(new OWOP.tool.class('Uran', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
- tool.setEvent('mousedown mousemove', function (mouse, event) {
- placeUran(mouse.tileX,mouse.tileY);
- }
- );
- tool.setEvent('mouseup mousemove', function (mouse) {
- OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
- });}));
- OWOP.tool.addToolObject(new OWOP.tool.class('Plut', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
- tool.setEvent('mousedown mousemove', function (mouse, event) {
- placePlut(mouse.tileX,mouse.tileY);
- }
- );
- tool.setEvent('mouseup mousemove', function (mouse) {
- OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
- });}));
- OWOP.tool.addToolObject(new OWOP.tool.class('Uran2', OWOP.cursors.uran, OWOP.fx.player.RECT_SELECT_ALIGNED(1), false, function(tool){
- tool.setEvent('mousedown mousemove', function (mouse, event) {
- placeUran2(mouse.tileX,mouse.tileY);
- }
- );
- tool.setEvent('mouseup mousemove', function (mouse) {
- OWOP.world.setPixel(mouse,tileX,mouse.tileY,[255,255,255]);
- });}));
- },5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement