Guest User

Untitled

a guest
Jul 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro Live Player Position
  3. // @version 0.5
  4. // @include http://*.koalabeast.com:*
  5. // @include http://*.jukejuice.com:*
  6. // @include http://*.newcompte.fr:*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function init(initTime) {
  11. if (typeof tagpro === "undefined" || !tagpro.playerId) {
  12. if (Date.now() - initTime > 10000) return;
  13. return setTimeout(init, 100, initTime);
  14. }
  15. setTimeout(startFunction, 3000);
  16. })(Date.now());
  17.  
  18. function startFunction() {
  19. var tr = tagpro.renderer;
  20. var upsp = tr.updatePlayerSpritePosition;
  21.  
  22. tr.render = function() {
  23. requestAnimationFrame(tr.render);
  24. tagpro.world.update();
  25. tr.updateGraphics();
  26. tagpro.ui.update();
  27. tr.renderer.render(tr.stage);
  28. tr.measurePerformance();
  29. tr.lastFrameTime=performance.now();
  30. };
  31.  
  32. Box2D.Dynamics.b2Body.prototype.GetPosition = function() {
  33. if (!this.player || !this.player.id) {
  34. return this.m_xf.position;
  35. }
  36. if (!tagpro.players[this.player.id].pos) {
  37. tagpro.players[this.player.id].pos = this.m_xf.position;
  38. }
  39. return this.m_xf.position;
  40. };
  41.  
  42. tr.updatePlayerSpritePosition = function(player) {
  43. upsp.apply(this, arguments);
  44. var position = player.pos || {x: player.x / 100, y: player.y / 100};
  45. player.sprite.x = position.x * 100;
  46. player.sprite.y = position.y * 100;
  47. };
  48.  
  49. tr.centerContainerToPoint = function(x, y) {
  50. var r = tr.options.disableViewportScaling ? 1 : (this.vpHeight / tr.canvas_height).toFixed(2);
  51. if (tagpro.viewport.followPlayer) {
  52. var self = tagpro.players[tagpro.playerId];
  53. var position = self.pos || {x: self.x / 100, y: self.y / 100};
  54. x = position.x * 100 + 20;
  55. y = position.y * 100 + 20;
  56. }
  57. if (x <= -980 && y <= -980) {
  58. return;
  59. }
  60. tr.gameContainer.x = this.vpWidth / 2 - x / tagpro.zoom * r;
  61. tr.gameContainer.y = this.vpHeight / 2 - y / tagpro.zoom * r;
  62. };
  63.  
  64. tr.updateCameraPosition = function() {
  65. tr.centerContainerToPoint();
  66. };
  67. }
Add Comment
Please, Sign In to add comment