Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. var timer1;
  2. var array = [];
  3. var odleglosc;
  4. var porowodl;
  5. var aktu_mob;
  6. var ignorate=[146347,146348]
  7.  
  8.  
  9. function sell()
  10. {
  11.  
  12. for(let i in g.item)
  13. {
  14. if(g.item[i].st==0&&g.item[i].loc!="m")
  15. {
  16. array.push(g.item[i].id);
  17. }
  18. }
  19.  
  20. };
  21.  
  22.  
  23. function sprawdzanie_po_drodze()
  24. {
  25. var odleg2 = [];
  26. for(let i in g.npc)
  27. {
  28. if(g.npc[i].wt<10 && g.npc[i].type>0 && g.npc[i].type<4 && g.npc[i].lvl>=lvlmin && g.npc[i].lvl<=lvlmax&& ignorate[0]!=g.npc[i].id && ignorate[1]!=g.npc[i].id)
  29. {
  30. if(aktu_mob!=g.npc[i].id)
  31. {
  32. odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
  33. odleg2.push(odleglosc);
  34. }
  35.  
  36. }
  37. }
  38.  
  39. porowodl=Math.min.apply(null, odleg2); // 1
  40. setTimeout(sprawdzanie_po_drodze,300);
  41.  
  42. }sprawdzanie_po_drodze();
  43.  
  44.  
  45. function idz(x,y,id)
  46. {
  47.  
  48. timer1=setInterval(function(){
  49.  
  50. if(findEmptyBagPlace()==false){
  51. if(hero.x==61 && hero.y==31)
  52. {
  53. clearInterval(timer1);
  54. sell();
  55. _g("talk&id=142713");
  56. setTimeout(function(){document.querySelectorAll('#dialog #dlgin .replies li')[1].click() },90);
  57. setTimeout(function(){_g("shop&buy=&sell="+array.toString());},1000);
  58. setTimeout(function(){array.splice(0,array.length)},1200);
  59. setTimeout(function(){shop_close()},2000);
  60. setTimeout(function(){szuk()},3000);
  61.  
  62. }
  63. else
  64. {
  65.  
  66. goTo(61,31);
  67. }
  68. }
  69. else if(Math.abs(hero.x-x)<=1&&Math.abs(hero.y-y)<=1)
  70. {
  71. clearInterval(timer1);
  72. _g('fight&a=attack&id=-'+id+'&ff=1');
  73. setTimeout(function(){_g('fight&a=quit')},2000);
  74.  
  75. if(g.battle==false)
  76. {
  77. setTimeout(szuk,2000);
  78. }
  79.  
  80. return;
  81. }
  82. else
  83. {
  84.  
  85. if(porowodl<najbliższa)
  86. {
  87. clearInterval(timer1);
  88. console.log('[change] Zmieniona: '+porowodl)
  89. szuk();
  90. }
  91. else{
  92.  
  93. goTo(x,y);
  94. }
  95.  
  96. }
  97. },300)
  98.  
  99.  
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106. var najbliższa;
  107. var lvlmin=localStorage.getItem('lvl_min');
  108. var lvlmax=localStorage.getItem('lvl_max');
  109.  
  110. function addlvl(min,max)
  111. {
  112.  
  113. localStorage.setItem('lvl_max',max);
  114. localStorage.setItem('lvl_min',min);
  115. }
  116.  
  117.  
  118. function szuk()
  119. {
  120.  
  121. var odleg = [];
  122.  
  123. for(let i in g.npc)
  124. {
  125. if(g.npc[i].wt<10 && g.npc[i].type>0 && g.npc[i].type<4 && g.npc[i].lvl>=lvlmin && g.npc[i].lvl<=lvlmax&& ignorate[0]!=g.npc[i].id && ignorate[1]!=g.npc[i].id)
  126. {
  127.  
  128. odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
  129. odleg.push(odleglosc);
  130.  
  131. }
  132. }
  133.  
  134. najbliższa=Math.min.apply(null, odleg); // 1
  135.  
  136. for(let i in g.npc)
  137. {
  138. if(g.npc[i].wt<10 && g.npc[i].type>0 && g.npc[i].type<4 && g.npc[i].lvl>=lvlmin && g.npc[i].lvl<=lvlmax&& ignorate[0]!=g.npc[i].id && ignorate[1]!=g.npc[i].id)
  139. {
  140. odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
  141.  
  142. if(odleglosc==najbliższa)
  143. {
  144. console.log(g.npc[i]);
  145. console.log('[accept] Odległość: '+najbliższa)
  146. aktu_mob=g.npc[i].id;
  147. idz(g.npc[i].x,g.npc[i].y,g.npc[i].id)
  148. return;
  149.  
  150. }
  151.  
  152.  
  153. }
  154. }
  155.  
  156.  
  157. }
  158. setTimeout(szuk,6000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement