Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TagPro Cam's Spin Balls
- // @description Sexy spin ring and pixel perfect tagpro.
- // @version 3
- // @grant none
- // @include http://tagpro-*.koalabeast.com:*
- // @include http://tangent.jukejuice.com:*
- // @include http://*.newcompte.fr:*
- // @license 2015
- // @author CFlakes, Cam
- // @namespace http://www.reddit.com/user/Cumflakes
- // ==/UserScript==
- tagpro.ready(function () {
- var ballTexture = PIXI.Texture.fromImage('http://i.imgur.com/SH4LMYB.png'),
- redBall = new PIXI.Texture(ballTexture, new PIXI.Rectangle(0, 0, 40, 40)),
- blueBall = new PIXI.Texture(ballTexture, new PIXI.Rectangle(40, 0, 40, 40)),
- redRing = new PIXI.Texture(ballTexture, new PIXI.Rectangle(80, 0, 40, 40)),
- blueRing = new PIXI.Texture(ballTexture, new PIXI.Rectangle(120, 0, 40, 40)),
- tagproTexture = new PIXI.Texture(ballTexture, new PIXI.Rectangle(160, 0, 40, 40)),
- tr = tagpro.renderer;
- tr.updatePlayerColor = function (player) {
- var tileId = player.team === 1 ? "red" : "blue";
- if (player.sprites.actualBall.tileId !== tileId) {
- tr.createBallSprite(player);
- tr.createBallSpin(player);
- }
- };
- tr.createBallSprite = function (player) {
- var teamBall = player.team === 1 ? redBall : blueBall;
- if (!player.sprites.actualBall) {
- player.sprites.actualBall = new PIXI.Sprite(teamBall);
- player.sprites.actualBall.tileId = player.team === 1 ? 'red' : 'blue';
- player.sprites.ball.addChild(player.sprites.actualBall);
- } else {
- player.sprites.actualBall.setTexture(teamBall);
- player.sprites.actualBall.tileId = player.team === 1 ? 'red' : 'blue';
- }
- };
- tr.createBallSpin = function (player) {
- var teamSpin = player.team === 1 ? redRing : blueRing;
- if (!player.sprites.ring) {
- var shape = [0, 0, 40, 0, 20, 20, 40, 40, 0, 40, 20, 20, 0, 0];
- player.sprites.ringMask = new PIXI.Graphics();
- player.sprites.ringMask.beginFill(0x000000);
- player.sprites.ringMask.drawPolygon(shape);
- player.sprites.ringMask.endFill();
- player.sprites.ringMask.x = 20;
- player.sprites.ringMask.y = 20;
- player.sprites.ringMask.pivot.x = 20;
- player.sprites.ringMask.pivot.y = 20;
- player.sprites.ring = new PIXI.Sprite(teamSpin);
- player.sprites.ball.addChild(player.sprites.ring);
- player.sprites.ball.addChild(player.sprites.ringMask);
- player.sprites.ring.mask = player.sprites.ringMask;
- } else {
- player.sprites.ring.setTexture(teamSpin);
- }
- };
- var upsp = tr.updatePlayerSpritePosition;
- tr.updatePlayerSpritePosition = function (player) {
- if (!player.sprites.ring) {
- tr.createBallSpin(player);
- } else {
- player.sprites.ringMask.rotation = player.angle;
- }
- upsp(player);
- };
- tr.updateTagpro = function (player) {
- if (player.tagpro) {
- if (!tr.options.disableParticles && !player.sprites.tagproSparks) {
- player.sprites.tagproSparks = new cloudkid.Emitter(
- player.sprites.ball, [tr.particleFireTexture],
- tagpro.particleDefinitions.tagproSparks);
- tr.emitters.push(player.sprites.tagproSparks);
- }
- if (player.bomb) {
- if (player.sprites.tagproTint) {
- player.sprites.ball.removeChild(player.sprites.tagproTint);
- player.sprites.tagproTint = null;
- }
- } else {
- if (!player.sprites.tagproTint) {
- player.sprites.tagproTint = new PIXI.Graphics();
- player.sprites.tagproTint.beginFill(0x00FF00, 0.25).drawCircle(20, 20, 19);
- player.sprites.ball.addChild(player.sprites.tagproTint);
- }
- }
- if (!player.sprites.tagproTexture) {
- player.sprites.tagproTexture = new PIXI.Sprite(tagproTexture);
- player.sprites.ball.addChild(player.sprites.tagproTexture);
- }
- } else {
- if (player.sprites.tagproTint || player.sprites.tagproTexture) {
- player.sprites.ball.removeChild(player.sprites.tagproTint);
- player.sprites.ball.removeChild(player.sprites.tagproTexture);
- player.sprites.tagproTint = null;
- player.sprites.tagproTexture = null;
- }
- if (player.sprites.tagproSparks) {
- player.sprites.tagproSparks.emit = false;
- var sparksIndex = tr.emitters.indexOf(player.sprites.tagproSparks);
- tr.emitters.splice(sparksIndex, 1);
- player.sprites.tagproSparks.destroy();
- player.sprites.tagproSparks = null;
- }
- }
- };
- tr.updateRollingBomb = function (player) {
- if (player.bomb) {
- if (!player.sprites.bomb) {
- if (!tr.options.disableParticles) {
- player.sprites.rollingBomb = new cloudkid.Emitter(
- player.sprites.ball, [tr.particleTexture],
- tagpro.particleDefinitions.rollingBomb);
- tr.emitters.push(player.sprites.rollingBomb);
- }
- var bomb = player.sprites.bomb = new PIXI.Graphics();
- bomb.beginFill(0xFFFF00, 0.6).drawCircle(20, 20, 19);
- player.sprites.ball.addChild(bomb);
- } else {
- player.sprites.bomb.alpha = Math.abs(0.6 * Math.sin(performance.now() / 75));
- }
- } else {
- if (player.sprites.bomb) {
- player.sprites.ball.removeChild(player.sprites.bomb);
- player.sprites.bomb = null;
- }
- if (player.sprites.rollingBomb) {
- if (player.sprites.rollingBomb instanceof cloudkid.Emitter) {
- player.sprites.rollingBomb.emit = false;
- tr.emitters.splice(tr.emitters.indexOf(player.sprites.rollingBomb), 1);
- player.sprites.rollingBomb.destroy();
- } else {
- player.sprites.rollingBomb.visible = false;
- }
- player.sprites.rollingBomb = null;
- }
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment