Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var timer1;
- var array = [];
- var odleglosc;
- var porowodl;
- var aktu_mob;
- var ignorate=[146347,146348]
- function sell()
- {
- for(let i in g.item)
- {
- if(g.item[i].st==0&&g.item[i].loc!="m")
- {
- array.push(g.item[i].id);
- }
- }
- };
- function sprawdzanie_po_drodze()
- {
- var odleg2 = [];
- for(let i in g.npc)
- {
- 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)
- {
- if(aktu_mob!=g.npc[i].id)
- {
- odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
- odleg2.push(odleglosc);
- }
- }
- }
- porowodl=Math.min.apply(null, odleg2); // 1
- setTimeout(sprawdzanie_po_drodze,300);
- }sprawdzanie_po_drodze();
- function idz(x,y,id)
- {
- timer1=setInterval(function(){
- if(findEmptyBagPlace()==false){
- if(hero.x==61 && hero.y==31)
- {
- clearInterval(timer1);
- sell();
- _g("talk&id=142713");
- setTimeout(function(){document.querySelectorAll('#dialog #dlgin .replies li')[1].click() },90);
- setTimeout(function(){_g("shop&buy=&sell="+array.toString());},1000);
- setTimeout(function(){array.splice(0,array.length)},1200);
- setTimeout(function(){shop_close()},2000);
- setTimeout(function(){szuk()},3000);
- }
- else
- {
- goTo(61,31);
- }
- }
- else if(Math.abs(hero.x-x)<=1&&Math.abs(hero.y-y)<=1)
- {
- clearInterval(timer1);
- _g('fight&a=attack&id=-'+id+'&ff=1');
- setTimeout(function(){_g('fight&a=quit')},2000);
- if(g.battle==false)
- {
- setTimeout(szuk,2000);
- }
- return;
- }
- else
- {
- if(porowodl<najbliższa)
- {
- clearInterval(timer1);
- console.log('[change] Zmieniona: '+porowodl)
- szuk();
- }
- else{
- goTo(x,y);
- }
- }
- },300)
- }
- var najbliższa;
- var lvlmin=localStorage.getItem('lvl_min');
- var lvlmax=localStorage.getItem('lvl_max');
- function addlvl(min,max)
- {
- localStorage.setItem('lvl_max',max);
- localStorage.setItem('lvl_min',min);
- }
- function szuk()
- {
- var odleg = [];
- for(let i in g.npc)
- {
- 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)
- {
- odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
- odleg.push(odleglosc);
- }
- }
- najbliższa=Math.min.apply(null, odleg); // 1
- for(let i in g.npc)
- {
- 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)
- {
- odleglosc=Math.abs(hero.x - g.npc[i].x)+Math.abs(hero.y - g.npc[i].y);
- if(odleglosc==najbliższa)
- {
- console.log(g.npc[i]);
- console.log('[accept] Odległość: '+najbliższa)
- aktu_mob=g.npc[i].id;
- idz(g.npc[i].x,g.npc[i].y,g.npc[i].id)
- return;
- }
- }
- }
- }
- setTimeout(szuk,6000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement