UserNameWTF

Cam'sPP Spin Balls

Jan 27th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro Cam's Spin Balls
  3. // @description Sexy spin ring and pixel perfect tagpro.
  4. // @version 3
  5. // @grant none
  6. // @include http://tagpro-*.koalabeast.com:*
  7. // @include http://tangent.jukejuice.com:*
  8. // @include http://*.newcompte.fr:*
  9. // @license 2015
  10. // @author CFlakes, Cam
  11. // @namespace http://www.reddit.com/user/Cumflakes
  12. // ==/UserScript==
  13.  
  14. tagpro.ready(function () {
  15. var ballTexture = PIXI.Texture.fromImage('http://i.imgur.com/SH4LMYB.png'),
  16. redBall = new PIXI.Texture(ballTexture, new PIXI.Rectangle(0, 0, 40, 40)),
  17. blueBall = new PIXI.Texture(ballTexture, new PIXI.Rectangle(40, 0, 40, 40)),
  18. redRing = new PIXI.Texture(ballTexture, new PIXI.Rectangle(80, 0, 40, 40)),
  19. blueRing = new PIXI.Texture(ballTexture, new PIXI.Rectangle(120, 0, 40, 40)),
  20. tagproTexture = new PIXI.Texture(ballTexture, new PIXI.Rectangle(160, 0, 40, 40)),
  21. tr = tagpro.renderer;
  22.  
  23. tr.updatePlayerColor = function (player) {
  24. var tileId = player.team === 1 ? "red" : "blue";
  25. if (player.sprites.actualBall.tileId !== tileId) {
  26. tr.createBallSprite(player);
  27. tr.createBallSpin(player);
  28. }
  29. };
  30.  
  31. tr.createBallSprite = function (player) {
  32. var teamBall = player.team === 1 ? redBall : blueBall;
  33. if (!player.sprites.actualBall) {
  34. player.sprites.actualBall = new PIXI.Sprite(teamBall);
  35. player.sprites.actualBall.tileId = player.team === 1 ? 'red' : 'blue';
  36. player.sprites.ball.addChild(player.sprites.actualBall);
  37. } else {
  38. player.sprites.actualBall.setTexture(teamBall);
  39. player.sprites.actualBall.tileId = player.team === 1 ? 'red' : 'blue';
  40. }
  41. };
  42.  
  43. tr.createBallSpin = function (player) {
  44. var teamSpin = player.team === 1 ? redRing : blueRing;
  45. if (!player.sprites.ring) {
  46. var shape = [0, 0, 40, 0, 20, 20, 40, 40, 0, 40, 20, 20, 0, 0];
  47. player.sprites.ringMask = new PIXI.Graphics();
  48. player.sprites.ringMask.beginFill(0x000000);
  49. player.sprites.ringMask.drawPolygon(shape);
  50. player.sprites.ringMask.endFill();
  51. player.sprites.ringMask.x = 20;
  52. player.sprites.ringMask.y = 20;
  53. player.sprites.ringMask.pivot.x = 20;
  54. player.sprites.ringMask.pivot.y = 20;
  55. player.sprites.ring = new PIXI.Sprite(teamSpin);
  56. player.sprites.ball.addChild(player.sprites.ring);
  57. player.sprites.ball.addChild(player.sprites.ringMask);
  58. player.sprites.ring.mask = player.sprites.ringMask;
  59. } else {
  60. player.sprites.ring.setTexture(teamSpin);
  61. }
  62. };
  63.  
  64. var upsp = tr.updatePlayerSpritePosition;
  65. tr.updatePlayerSpritePosition = function (player) {
  66. if (!player.sprites.ring) {
  67. tr.createBallSpin(player);
  68. } else {
  69. player.sprites.ringMask.rotation = player.angle;
  70. }
  71. upsp(player);
  72. };
  73.  
  74. tr.updateTagpro = function (player) {
  75. if (player.tagpro) {
  76. if (!tr.options.disableParticles && !player.sprites.tagproSparks) {
  77. player.sprites.tagproSparks = new cloudkid.Emitter(
  78. player.sprites.ball, [tr.particleFireTexture],
  79. tagpro.particleDefinitions.tagproSparks);
  80. tr.emitters.push(player.sprites.tagproSparks);
  81. }
  82. if (player.bomb) {
  83. if (player.sprites.tagproTint) {
  84. player.sprites.ball.removeChild(player.sprites.tagproTint);
  85. player.sprites.tagproTint = null;
  86. }
  87. } else {
  88. if (!player.sprites.tagproTint) {
  89. player.sprites.tagproTint = new PIXI.Graphics();
  90. player.sprites.tagproTint.beginFill(0x00FF00, 0.25).drawCircle(20, 20, 19);
  91. player.sprites.ball.addChild(player.sprites.tagproTint);
  92. }
  93. }
  94. if (!player.sprites.tagproTexture) {
  95. player.sprites.tagproTexture = new PIXI.Sprite(tagproTexture);
  96. player.sprites.ball.addChild(player.sprites.tagproTexture);
  97. }
  98. } else {
  99. if (player.sprites.tagproTint || player.sprites.tagproTexture) {
  100. player.sprites.ball.removeChild(player.sprites.tagproTint);
  101. player.sprites.ball.removeChild(player.sprites.tagproTexture);
  102. player.sprites.tagproTint = null;
  103. player.sprites.tagproTexture = null;
  104. }
  105. if (player.sprites.tagproSparks) {
  106. player.sprites.tagproSparks.emit = false;
  107. var sparksIndex = tr.emitters.indexOf(player.sprites.tagproSparks);
  108. tr.emitters.splice(sparksIndex, 1);
  109. player.sprites.tagproSparks.destroy();
  110. player.sprites.tagproSparks = null;
  111. }
  112. }
  113. };
  114.  
  115. tr.updateRollingBomb = function (player) {
  116. if (player.bomb) {
  117. if (!player.sprites.bomb) {
  118. if (!tr.options.disableParticles) {
  119. player.sprites.rollingBomb = new cloudkid.Emitter(
  120. player.sprites.ball, [tr.particleTexture],
  121. tagpro.particleDefinitions.rollingBomb);
  122. tr.emitters.push(player.sprites.rollingBomb);
  123. }
  124. var bomb = player.sprites.bomb = new PIXI.Graphics();
  125. bomb.beginFill(0xFFFF00, 0.6).drawCircle(20, 20, 19);
  126. player.sprites.ball.addChild(bomb);
  127. } else {
  128. player.sprites.bomb.alpha = Math.abs(0.6 * Math.sin(performance.now() / 75));
  129. }
  130. } else {
  131. if (player.sprites.bomb) {
  132. player.sprites.ball.removeChild(player.sprites.bomb);
  133. player.sprites.bomb = null;
  134. }
  135. if (player.sprites.rollingBomb) {
  136. if (player.sprites.rollingBomb instanceof cloudkid.Emitter) {
  137. player.sprites.rollingBomb.emit = false;
  138. tr.emitters.splice(tr.emitters.indexOf(player.sprites.rollingBomb), 1);
  139. player.sprites.rollingBomb.destroy();
  140. } else {
  141. player.sprites.rollingBomb.visible = false;
  142. }
  143. player.sprites.rollingBomb = null;
  144. }
  145. }
  146. };
  147. });
Advertisement
Add Comment
Please, Sign In to add comment