Guest User

TagproSpin

a guest
Jul 11th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name            Tagpro Cam Spin Balls
  3. // @namespace       http://*.koalabeast.com:*
  4. // @version         1.4.1
  5. // @description     Semitransparent balls with spin and pixel perfect tagpro/rolling bomb.
  6. // @match           http://koalabeast.com
  7. // @copyright       2014+, Ly and a little bit of Cumflakes
  8. // @include         http://*.koalabeast.com*
  9. // @include         http://*.jukejuice.com*
  10. // @include         http://*.newcompte.fr*
  11. // @include         http://justletme.be*
  12. // ==/UserScript==
  13.  
  14. tagpro.ready(function(){
  15.    
  16.     //This is important.
  17.     if(tagpro.events.drawPlayer)
  18.         return;
  19.     var image = new Image();
  20.     image.src = "http://i.imgur.com/yhevops.png";
  21.    
  22.     tagpro.events.register({
  23.         drawPlayer: function(player, context, drawPos, TILESIZE) {
  24.            
  25.             if (player.team == 1)
  26.                 context.drawImage(image, 3 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  27.             if (player.team == 2)
  28.                 context.drawImage(image, 1 * 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  29.            
  30.             var radian = (Math.PI / 180),
  31.                 points = [],
  32.                 angle = (player.angle/radian % 360)+427.5;
  33.            
  34.             for (i = 0; i < 8; i++) {
  35.                 var iAngle = angle + 360 / 8 * i,
  36.                     side = ((iAngle + 270) % 360 > 180) ? 0 : -0,
  37.                     outerAngle = (iAngle + 90) % 180,
  38.                     outerAngle = (side > 0) ? 180 - outerAngle : outerAngle,
  39.                     offset = (-8.546e-10 * Math.pow(outerAngle, 5)
  40.                               + 4.311e-7 * Math.pow(outerAngle, 4)
  41.                               - 6.669e-5 * Math.pow(outerAngle, 3)
  42.                               + 0.001099 * Math.pow(outerAngle, 2)
  43.                               + 0.3462 * outerAngle),
  44.                     innerX = 18 * Math.cos(iAngle * radian) / tagpro.zoom,
  45.                     innerY = 18 * Math.sin(iAngle * radian) / tagpro.zoom,
  46.                     outerX = 30 * Math.cos((iAngle + offset * side) * radian) / tagpro.zoom,
  47.                     outerY = 30 * Math.sin((iAngle + offset * side) * radian) / tagpro.zoom;
  48.                
  49.                 points.push({ix: innerX, iy: innerY, ox: outerX, oy: outerY});
  50.             }
  51.            
  52.             for (i = 0; i < points.length; i += 2) {
  53.                 var color = (player.team == 1) ? 2 : 0;
  54.                 first = points[i],
  55.                     second = points[(i + 1) % points.length];
  56.                
  57.                 context.save();
  58.                 context.beginPath();
  59.                 context.moveTo(drawPos.x + 20 / tagpro.zoom, drawPos.y + 20 / tagpro.zoom);
  60.                 context.quadraticCurveTo(drawPos.x + first.ix + 20 / tagpro.zoom, drawPos.y + first.iy + 20 / tagpro.zoom, drawPos.x + first.ox + 20 / tagpro.zoom, drawPos.y + first.oy + 20 / tagpro.zoom);
  61.                 context.lineTo(drawPos.x + second.ox + 20 / tagpro.zoom, drawPos.y + second.oy + 20 / tagpro.zoom);
  62.                 context.quadraticCurveTo(drawPos.x + second.ix + 20 / tagpro.zoom, drawPos.y + second.iy + 20 / tagpro.zoom, drawPos.x + 20 / tagpro.zoom, drawPos.y + 20 / tagpro.zoom);
  63.                 context.clip();
  64.                 context.drawImage(image, color * 40, 0, 40, 40  , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  65.                 context.restore();
  66.                 context.closePath();
  67.             }
  68.            
  69.             if (player.tagpro)
  70.                 context.drawImage(image, 5 * 40, 0, 40, 40      , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  71.             else
  72.                 context.drawImage(image, 4 * 40, 0, 40, 40      , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  73.            
  74.             if (player.bomb && Math.round(Math.random() * 4) == 1) {
  75.                 context.globalAlpha = 0.7;
  76.                 context.drawImage(image, 6 * 40, 0, 40, 40      , drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  77.                 context.globalAlpha = 1;
  78.             }
  79.         }
  80.     });
  81. });
Advertisement
Add Comment
Please, Sign In to add comment