satiel7314

Untitled

Sep 17th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Autodobijanie NI
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://tempest.margonem.pl/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (Engine => {
  12.  
  13. function algorytm()
  14. {
  15. var targets = [];
  16. if(Engine.map.d.pvp == 2 && document.getElementById('trigger').checked)
  17. {
  18. var minLvl = document.getElementById('minLvl').value;
  19. var maxLvl = document.getElementById('maxLvl').value;
  20. var backX = document.getElementById('backX').value;
  21. var backY = document.getElementById('backY').value;
  22.  
  23. if(minLvl == ''){minLvl = 0}
  24. if(maxLvl == ''){maxLvl = 300}
  25.  
  26. var eee = Engine.others.getDrawableList().filter(obj => {return obj.d});
  27. var others = eee.filter(obj => {return (obj.d.relation == 'en' || obj.d.relation == 'cl-en' || obj.d.relation == '') && obj.d.lvl > minLvl && obj.d.lvl < maxLvl});
  28. for(var i in others)
  29. {
  30. var emo = others[i].onSelfEmoList[0];
  31. if(emo == undefined){
  32. targets.push({id: others[i].d.id, x: others[i].d.x, y: others[i].d.y, distance: Math.abs(Engine.hero.d.x - others[i].d.x) + Math.abs(Engine.hero.d.y - others[i].d.y)})
  33. }
  34. else if(emo.name != 'battle' && emo.name != 'pvpprotected'){
  35. targets.push({id: others[i].d.id, x: others[i].d.x, y: others[i].d.y, distance: Math.abs(Engine.hero.d.x - others[i].d.x) + Math.abs(Engine.hero.d.y - others[i].d.y)})
  36. }
  37. }
  38. if(targets != '')
  39. {
  40. targets = targets.sort((a, b) => (a.distance > b.distance) ? 1 : -1);
  41. if(targets[0].distance > 2){Engine.hero.autoGoTo({x: targets[0].x, y: targets[0].y})}
  42. else{window._g('fight&a=attack&id='+targets[0].id)}
  43. }
  44. else if(document.getElementById('backChecker').checked && backX != Engine.hero.d.x && backX != '' && backY != Engine.hero.d.y && backY != '')
  45. {
  46. Engine.hero.autoGoTo({x: eval(backX), y: eval(backY)});
  47. }
  48. }
  49. setTimeout(algorytm, 50);
  50. }
  51.  
  52. function css()
  53. {
  54. const $container2 = $( '<div id="container2"></div>' );
  55. const $trigger = $('<input type="checkbox" id="trigger">ON/OFF</br>');
  56. const $minLvl = $('<input type="text" class="input" id="minLvl" autocomplete="off" placeholder="Min lvl"></br>');
  57. const $maxLvl = $('<input type="text" class="input" id="maxLvl" autocomplete="off" placeholder="Max lvl" value="301"></br>');
  58. const $backChecker = $('<input type="checkbox" id="backChecker">');
  59. const $backX = $('<input type="number" class="backInput" id="backX" placeholder="X">');
  60. const $backY = $('<input type="number" class="backInput" id="backY" placeholder="Y"></br>');
  61. const $backButton = $('<button id="backButton">Kordy</button>');
  62. $("body").append($container2);
  63. $("#container2").append($trigger, $minLvl, $maxLvl, $backChecker, $backX, $backY, $backButton);
  64.  
  65. $( "#container2" ).css({
  66. 'position': 'absolute',
  67. 'text-align': 'center',
  68. 'width': '85px',
  69. 'height': '120px',
  70. 'background': '#474747',
  71. 'font-family': 'Segoe UI',
  72. 'top': '80.5%',
  73. 'left': '95.3%',
  74. 'border-radius': '3px',
  75. 'border': '1px solid black',
  76. 'z-index': '999'
  77. });
  78. $( "#backButton" ).css({
  79. 'margin-top': '5px',
  80. 'height': '18px',
  81. 'width': '48px',
  82. 'background':'#918d83'
  83. });
  84. $( ".input" ).css({
  85. 'width': '50px'
  86. });
  87. $( ".backInput" ).css({
  88. 'margin-top': '6px',
  89. 'height': '15px',
  90. 'width': '19px'
  91. });
  92.  
  93. $( "#backButton" ).on( 'click', function() {
  94. document.getElementById('backX').value = Engine.hero.d.x;
  95. document.getElementById('backY').value = Engine.hero.d.y;
  96. });
  97. }
  98.  
  99. window.onload = css();
  100. window.onload = algorytm();
  101. })(window.Engine)
Add Comment
Please, Sign In to add comment