//////////////////////////////////////////////////////////////////////////////// // Mopar's RoadRunner (pun intended :P) v1.1 // //////////////////////////////////////////////////////////////////////////////// // SET UP // //////////////////////////////////////////////////////////////////////////////// // to use the road following procedures, set moparsroadcolor in your script // // the coords of colors found are saved in variables colorx and colory // //////////////////////////////////////////////////////////////////////////////// // Versions // //////////////////////////////////////////////////////////////////////////////// // Version 0.7, All colorfinding procedures done, beta fally walking // // Version 1.0, All walking procedures, fally and varrock bank-mine walking // // Version 1.1, Ardougne bank-mine walking done // //////////////////////////////////////////////////////////////////////////////// // Bugs/help etc. // //////////////////////////////////////////////////////////////////////////////// // post them in the thread on kaitnieks.com, or msg me on msn messenger at // // moparisthebest@hotmail.com // //////////////////////////////////////////////////////////////////////////////// const randomclick=5; // how random the mouseclick is maxpoints=10; // (default 10)maximum number of coords your going to send in your array var colorx,colory,moparsroadcolor:integer; coords:Array[1..12] of integer; Function chkroadcolor:boolean; begin if(moparsroadcolor=0)then writeln('you need to set moparsroadcolor before calling this function'); result:=(moparsroadcolor=0); end; Procedure roadrunnerFlag; // taken from ssi2 var flagimage,timeout,x,y:integer; begin flagimage := BitmapFromString(2, 2,'FF00005D3311C656045D3311'); timeout:=0 repeat timeout:=timeout+1; wait(250); until(not findbitmapin( flagimage, x, y, 570, 5, 725, 162)) or (timeout > 120); freebitmap(flagimage); end; Procedure roadrunnerantiFlag; // waits till flag does exist var flagimage,timeout,x,y:integer; begin flagimage := BitmapFromString(2, 2,'FF00005D3311C656045D3311'); timeout:=0 if(not findbitmapin( flagimage, x, y, 570, 5, 725, 162))then begin repeat timeout:=timeout+1; wait(250); until(not findbitmapin( flagimage, x, y, 570, 5, 725, 162)) or (timeout > 120); end; freebitmap(flagimage); end; Procedure roadrunnerMouse(mousex,mousey:integer); //modified from ssi2 var a,b,c,randx,randy:integer; begin case (random(4)+1) of 1:begin randx:=mousex+random(randomclick);randy:=mousey+random(randomclick);end; 2:begin randx:=mousex-random(randomclick);randy:=mousey-random(randomclick);end; 3:begin randx:=mousex+random(randomclick);randy:=mousey-random(randomclick);end; 4:begin randx:=mousex-random(randomclick);randy:=mousey+random(randomclick);end; end; MoveMouseSmoothEx(randx+1,randy, 2, 4, 30, 20, 10) sleep(50+random(50)); GetMousePos(b,c); HoldMouse(b+1,c,true); repeat wait(10+random(40)); a:=a+1; until(a>4); GetMousePos(b,c); ReleaseMouse(b,c,true); wait(500+random(100)); roadrunnerantiFlag; wait(1000+random(100)); roadrunnerFlag; end; function roadrunnerfindcolor(color:integer):boolean; begin result:=(findcolorspiral(colorx,colory,color,565,5,725,160)); end; ///////////////////////////////////////////////////// //finds color along the ycoord, from startx to endx// ///////////////////////////////////////////////////// Function findhorizcolor(color,ycoord,startx,endx:integer):boolean; var found:boolean; begin colorx:=startx; colory:=ycoord; found:=false; repeat found:=(getcolor(colorx,ycoord)=color); if((not(found))and(startx>endx))then colorx:=colorx-1; if((not(found))and(not(startx>endx)))then colorx:=colorx+1; until((found)or((colorxendx))or((colorx>endx)and(not(startx>endx)))) result:=found; end; ///////////////////////////////////////////////////// //finds color along the xcoord, from starty to endy// ///////////////////////////////////////////////////// Function findvertcolor(color,xcoord,starty,endy:integer):boolean; var found:boolean; begin colorx:=xcoord; colory:=starty; found:=false; repeat found:=(getcolor(xcoord,colory)=color); if((not(found))and(starty>endy))then colory:=colory-1; if((not(found))and(not(starty>endy)))then colory:=colory+1; until((found)or((coloryendy))or((colory>endy)and(not(starty>endy)))) result:=found; end; /////////////////////////////////////////////////////// //finds color along the straight line drawn from // // the startcoords to the endcoords // /////////////////////////////////////////////////////// Function findlinecolor(color,startx,starty,endx,endy:integer):boolean; var found,posx,posy:boolean; slopex,slopey:Extended; begin if(startx=endx)and(starty=endy)then begin result:=false; exit; end; if(startx=endx)then result:=findvertcolor(color,startx,starty,endy); if(starty=endy)then result:=findhorizcolor(color,starty,startx,endx); if((not(starty=endy))and(not(startx=endx)))then begin slopex:=startx-endx; posx:=(slopex>=0); slopey:=starty-endy; posy:=(slopey>=0); if(slopex>slopey)then begin slopey:=abs(slopey/slopex); slopex:=1; end; if(slopey>slopex)then begin slopex:=abs(slopex/slopey); slopey:=1; end; colorx:=startx; colory:=starty; found:=false; repeat found:=(getcolor(colorx,colory)=color); if(not(found))then begin if(posx)then colorx:=round(colorx-slopex); if(posy)then colory:=round(colory-slopey); if(not(posx))then colorx:=round(colorx+slopex); if(not(posy))then colory:=round(colory+slopey); end; //movemousesmooth(colorx,colory); //wait(10); until(found)or(colorx=endx)or(colory=endy) result:=found; end; end; /////////////////////////////////////////////////////////////////////////////// //finds color along the multiple connected lines drawn from the coords array,// //loaded with the x's in the odd numbers and the y's in the even numbers // /////////////////////////////////////////////////////////////////////////////// Function findcurvedlinecolor(color:integer):boolean; var c:integer; found:boolean; begin c:=1; repeat found:=findlinecolor(color,coords[(c)],coords[(c+1)],coords[(c+2)],coords[(c+3)]); c:=c+2; until(found)or(12<(c+2)) result:=found; end; ///////////////////////////////////////////////////////////// //finds a road in the given direction, from the given side,// ///////////////////////////////////////////////////////////// Function findroad(direction,fromside:string):boolean; var toporleft:boolean; begin case fromside of 'T','t','TOP' : toporleft:=true; 'B','b','BOTTOM' : toporleft:=false; 'R','r','RIGHT' : toporleft:=false; 'L','l','LEFT' : toporleft:=true; end; case direction of 'N','n','NORTH': begin if(toporleft)then result:=(findhorizcolor(moparsroadcolor,30,595,700)); if(not(toporleft))then result:=(findhorizcolor(moparsroadcolor,30,700,595)); end; 'E','e','EAST' : begin if(toporleft)then result:=(findvertcolor(moparsroadcolor,696,25,125)); if(not(toporleft))then result:=(findvertcolor(moparsroadcolor,696,125,25)); end; 'S','s','SOUTH': begin if(toporleft)then result:=(findhorizcolor(moparsroadcolor,125,595,700)); if(not(toporleft))then result:=(findhorizcolor(moparsroadcolor,125,700,595)); end; 'W','w','WEST' : begin if(toporleft)then result:=(findvertcolor(moparsroadcolor,600,25,125)); if(not(toporleft))then result:=(findvertcolor(moparsroadcolor,600,125,25)); end; 'NW','nw','NORTHWEST': begin if(toporleft)then result:=(findlinecolor(moparsroadcolor,648,8,574,79)); if(not(toporleft))then result:=(findlinecolor(moparsroadcolor,574,79,648,8)); end; 'NE','ne','NORTHEAST' : begin if(toporleft)then result:=(findlinecolor(moparsroadcolor,648,8,720,79)); if(not(toporleft))then result:=(findlinecolor(moparsroadcolor,720,79,648,8)); end; 'SW','sw','SOUTHWEST': begin if(toporleft)then result:=(findlinecolor(moparsroadcolor,574,79,647,141)); if(not(toporleft))then result:=(findlinecolor(moparsroadcolor,647,141,574,79)); end; 'SE','se','SOUTHWEST' : begin if(toporleft)then result:=(findlinecolor(moparsroadcolor,720,79,647,141)); if(not(toporleft))then result:=(findlinecolor(moparsroadcolor,647,141,720,79)); end; end; end; /////////////////////////////////////////////////////////////////////////////// //walks in a direction, along the specified side of road, for specified steps// /////////////////////////////////////////////////////////////////////////////// procedure walkalongsteps(direction,fromside:string;steps:integer); var i:integer; begin if(chkroadcolor)then Exit; repeat i:=i+1; if(not(steps=1))then status('Walking '+direction+' '+inttostr(i)+'/'+inttostr(steps)); if(findroad(direction,fromside))then roadrunnerMouse(colorx,colory); until(i=steps) status(''); end; ///////////////////////////////////////////////////////////////////////// //same as above, except walks until turn found or maxsteps are reached// ///////////////////////////////////////////////////////////////////////// procedure walkuntilfindturn(direction,fromside,turndirection,turnfromside:string;maxsteps:integer); var i:integer; begin repeat i:=i+1; status('Walking '+direction+' '+inttostr(i)+'/'+inttostr(maxsteps)+' or find '+turndirection+' road'); walkalongsteps(direction,fromside,1); until((findroad(turndirection,turnfromside))or(i=maxsteps)) status(''); end; ///////////////////////////////////////////////////////////////////////// //same as above, except walks until color found or maxsteps are reached// ///////////////////////////////////////////////////////////////////////// procedure walkuntilfindcolor(direction,fromside:string;color,maxsteps:integer); var i:integer; begin repeat i:=i+1; status('Walking '+direction+' '+inttostr(i)+'/'+inttostr(maxsteps)+' or color found'); walkalongsteps(direction,fromside,1); until((roadrunnerfindcolor(color))or(i=maxsteps)) status(''); end; procedure didwalkingfail(town:string;color:integer); var fakex,fakey:integer; begin if(not(findcolorspiral(fakex,fakey,color,565,5,725,160)))then begin writeln(town+' walking failed, ending script'); terminatescript; end; end; procedure fallybanktomine(mappickcolor:integer); begin walkalongsteps('S','R',6); walkuntilfindturn('S','R','W','B',3); walkuntilfindturn('W','T','S','R',4); roadrunnerMouse(colorx,colory); if(not(mappickcolor=0))then begin repeat roadrunnerMouse(648,127); until(roadrunnerfindcolor(mappickcolor)) roadrunnerMouse(colorx-15,colory-15); didwalkingfail('fallybanktomine',mappickcolor); end; if(mappickcolor=0)then begin roadrunnerMouse(648,127); roadrunnerMouse(648,127); roadrunnerMouse(648,127); end; end; procedure fallyminetobank(banklogo:integer); begin if(not(findroad('N','R')))then roadrunnerMouse(627,50); if(findroad('N','R'))then roadrunnerMouse(colorx,colory); wait(500+random(200)); roadrunnerflag; walkuntilfindturn('NE','B','E','B',5); roadrunnerMouse(colorx,colory); walkuntilfindturn('E','B','N','L',2); walkuntilfindcolor('N','R',banklogo,9); roadrunnerMouse(colorx,colory); wait(500+random(200)); roadrunnerflag; didwalkingfail('fallyminetobank',banklogo); end; procedure varrockbanktomine(mappickcolor:integer); begin walkalongsteps('E','B',1); walkuntilfindturn('E','B','S','R',3); if(not(mappickcolor=0))then begin walkuntilfindcolor('S','R',mappickcolor,9); roadrunnerMouse(colorx,colory); didwalkingfail('varrockbanktomine',mappickcolor); end; if(mappickcolor=0)then begin walkalongsteps('S','R',6); end; end; procedure varrockminetobank(banklogo:integer); begin walkalongsteps('NE','T',1); walkalongsteps('N','R',2); walkuntilfindturn('N','R','W','T',8); walkuntilfindcolor('W','B',banklogo,5); roadrunnerMouse(colorx,colory); didwalkingfail('varrockminetobank',banklogo); end; procedure ardybanktomine(mappickcolor:integer); begin if(findhorizcolor(moparsroadcolor,86,720,654))then begin roadrunnerMouse(colorx,colory); wait(10000+random(500)); roadrunnerantiflag; roadrunnerflag; end; if(not(mappickcolor=0))then begin walkalongsteps('NE','B',2); walkuntilfindcolor('NE','B',mappickcolor,3); roadrunnerMouse(colorx,colory); didwalkingfail('ardybanktomine',mappickcolor); end; if(mappickcolor=0)then walkalongsteps('NE','B',4); end; procedure ardyminetobank(banklogo:integer); begin if(findhorizcolor(moparsroadcolor,80,719,575))then roadrunnerMouse(colorx,colory); walkuntilfindcolor('SW','B',banklogo,8); roadrunnerMouse(colorx+15,colory); if(findcolorspiral(colorx,colory,banklogo,565,5,725,160))then roadrunnerMouse(colorx-15,colory); didwalkingfail('ardyminetobank',banklogo); end;