Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Viewport Expander
  3. // @version 1.2
  4. // @description Maximize viewport and draw FOV
  5. // @author Catalyst
  6. // @include http://*.koalabeast.com:*
  7. // @include http://*.jukejuice.com:*
  8. // @include http://*.newcompte.fr:*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //--------------SETTINGS--------------
  13. //Set your monitor resolution below
  14. var max_horizontal=1920;//1536//1818
  15. var max_vertical=895;//960;//800//864
  16. //Change the following variable according to your league's whitelist rules.
  17. //Set the value to false to allow use in-game. Set the value to true to enable spectator-only mode (allowed in any league).
  18. var spec_only=true;
  19. //Set true/false to toggle auto-zoom level when spectating
  20. var auto_zoom=true;
  21. //Field of view color settings (does not show in spectator mode):
  22. // color in hex with 0x prefix
  23. // alpha controls the transparency and ranges from 0 (transparent) to 1 (opaque)
  24. var color=0x595959;
  25. var alpha=0.5;
  26. //-----------END OF SETTINGS-----------
  27.  
  28.  
  29. var oldh=0;
  30. var oldw=0;
  31. tagpro.ready(function waitForId() {
  32. if (!tagpro.playerId) {
  33. return setTimeout(waitForId, 100);
  34. }
  35. if(tagpro.spectator || !spec_only)
  36. {
  37. //Resize viewport
  38. tagpro.renderer.canvas_width = max_horizontal;//max horizontal resolution
  39. tagpro.renderer.canvas_height = max_vertical;//max vertical resolution
  40. //Check for resizing and update FOV and zoom accordingly
  41. setInterval(updateFOV, 500);
  42. }
  43. });
  44.  
  45. function updateFOV() {
  46. var h = $('#viewport').height();
  47. var w = $('#viewport').width();
  48. //Draw FOV
  49. if(!tagpro.spectator)
  50. {
  51. var player = tagpro.players[tagpro.playerId];
  52. if (!player.sprites.FOV) {
  53. player.sprites.FOV = new PIXI.Graphics();
  54. player.sprites.ball.addChild(player.sprites.FOV);
  55. }
  56. var x1=18-w/2;
  57. var x2=19+w/2;
  58. var y1=18-h/2;
  59. var y2=19+h/2;
  60. player.sprites.FOV.clear();
  61. player.sprites.FOV.beginFill(color);
  62. player.sprites.FOV.drawPolygon(x1,y1, x2,y1, x2,y2, x1,y2, x1,y1, -621,-381, 659,-381, 659,419, -621,419, -621,-381);
  63. player.sprites.FOV.endFill();
  64. player.sprites.FOV.alpha=alpha;
  65. }
  66. //Auto-zoom to fill viewport
  67. if(tagpro.spectator && auto_zoom && (oldh!=h ||oldw!=w))
  68. {
  69. var yzoom=tagpro.map[0].length*40/h;
  70. var xzoom=tagpro.map.length*40/w;
  71. tagpro.zoom=Math.max(xzoom,yzoom,1);
  72. }
  73. oldh=h;
  74. oldw=w;
  75. //Move viewport
  76. $('#viewport').css({
  77. 'top': '125px'
  78. });
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement