briochemc

tagpro OLTP2 jerseys

Aug 20th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          OLTP2_Jerseys_script
  3. // @namespace     http://www.reddit.com/user/NewCompte
  4. // @description   Rotating Transparent Jerseys on Radian's texture pack
  5. // @include       http://*.koalabeast.com:*
  6. // @license       GPL
  7. // @author        NewCompte, modified by brioche
  8. // @version       1
  9. // ==/UserScript==
  10.  
  11. // set team jersesy for the right color HERE
  12. blueTeamJerseyIndex = 5                  
  13. redTeamJerseyIndex = 5
  14. // This is for other jerseys than the first 2 ones
  15. blueTeamJerseyOption = 0
  16. redTeamJerseyOption = 0
  17.  
  18. function myRotatingBallsScript() {
  19.     tagpro.ready(function(){
  20.         //This is important.
  21.         if(tagpro.events.drawPlayer)
  22.             return;
  23.        
  24.         // Test for oltp
  25.         var jerseysOLTP = new Image();
  26.         jerseysOLTP.src = "http://i.imgur.com/KLsr6JU.png";
  27.         var BorderLight = new Image();
  28.         BorderLight.src = "http://i.imgur.com/GZ6E6Sr.png";
  29.        
  30.         // Muscle cup texture pack:
  31.         document.getElementById("tiles").src = "http://i.imgur.com/ggmGe81.png";
  32.         document.getElementById("splats").src = "http://i.imgur.com/3m8yX7z.png";
  33.         document.getElementById("speedpad").src = "http://i.imgur.com/M00rUPA.png";
  34.         document.getElementById("speedpadred").src = "http://i.imgur.com/PgDCaGU.png";
  35.         document.getElementById("speedpadblue").src = "http://i.imgur.com/1dgjMlf.png";
  36.         document.getElementById("portal").src = "http://i.imgur.com/qDUaiqD.png";
  37.  
  38.         //Wait 1 second then redraw textures
  39.         setTimeout(tagpro.api.redrawBackground,1000);
  40.            
  41.         if (tagpro.events.drawPlayer) {return;}
  42.            
  43.         tagpro.events.register({
  44.             drawPlayer: function(player, context, drawPos, TILESIZE) {
  45.                
  46.                 // Draw rotating jersey
  47.                 context.save();
  48.                 context.globalAlpha = 1; // Here is transparency
  49.                 context.translate(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom));
  50.                 context.rotate(player.angle);
  51.                 context.translate(-drawPos.x - (TILESIZE / 2) * (1 / tagpro.zoom), -drawPos.y - (TILESIZE / 2) * (1 / tagpro.zoom));
  52.                 if (player.team == 1)
  53.                 context.drawImage(jerseysOLTP, 80 + redTeamJerseyOption*80, redTeamJerseyIndex * 40, 40, 39, drawPos.x, drawPos.y, 40 / tagpro.zoom, 39 / tagpro.zoom);
  54.                 if (player.team == 2)
  55.                 context.drawImage(jerseysOLTP, 120 + blueTeamJerseyOption*80, blueTeamJerseyIndex * 40, 40, 39, drawPos.x, drawPos.y, 40 / tagpro.zoom, 39 / tagpro.zoom);
  56.                 context.restore();
  57.                
  58.                 // Draw muscle cup border
  59.                 context.drawImage(BorderLight, 0, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
  60.                
  61.                 // Draw pixel perfect rolling bomb
  62.                 if (player.bomb && Math.round(Math.random() * 4) == 1) {
  63.                     context.fillStyle = "rgba(255, 255, 0, .60)";
  64.                     context.beginPath();
  65.                     context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 17  * (1 / tagpro.zoom), 0, Math.PI*2, true);
  66.                     context.closePath();
  67.                     context.fill();
  68.                 };
  69.  
  70.                 // Draw pixel perfect tagpro
  71.                 if (player.tagpro) {
  72.                     context.strokeStyle = "#00FF00";
  73.                     context.fillStyle = "rgba(0, 255, 0, .20)";
  74.                     context.lineWidth = 2 * (1 / tagpro.zoom);
  75.                     context.beginPath();
  76.                     context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 16  * (1 / tagpro.zoom), 0, Math.PI*2, true);
  77.                     context.closePath();
  78.                     if (!player.bomb)
  79.                         context.fill();
  80.                     context.stroke();
  81.                 }
  82.  
  83.             }
  84.         });
  85.     });
  86. }
  87.  
  88. var source = "("+ myRotatingBallsScript + ")()";
  89. var script = document.createElement('script');
  90. script.setAttribute("type", "application/javascript");
  91. script.textContent = source;
  92.  
  93. document.body.appendChild(script);
Add Comment
Please, Sign In to add comment