SRL Archive - Outdated / Broken

Yet another Varock Miner


dontpanic

2007-02-10 11:36:33

This script mines iron/tin/copper at varock east.

Features:
- Banks or drops
- Detects if it should mine iron based on mining lvl
- Can bank iron and drop tin/copper or bank both or drop both

instructions:
- Fill out player setup
- Fill out other setup if you wish to change what rocks it mines/ what rocks it banks (it is currently set up to mine iron at lvl 30+ and bank iron and drop tin/copper
- Select client
- Hit run

Please post how it works. Note: it does not yet have a progress report

{.include srl/srl.scar}
{.include SRL/SRL/Skill/Mining.scar}


const
LoadsPerPlayer = 4;
IronLevel = 30; //Set to 100 to only mine tin/copper
DropTinCopper = true; //Do you want to powermine tin and copper
DropIron = false; //Do you want to powermine iron
TinColor = 8290184;
CopperColor = 4088199;
IronColor = 2305870;

Procedure DeclarePlayers;
Begin
HowManyPlayers := 7;
NumberOfPlayers( HowManyPlayers );
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=true;

Players[1].Name :='';
Players[1].Pass :='';
Players[1].Nick :='';
Players[1].Active:=true;

Players[2].Name :='';
Players[2].Pass :='';
Players[2].Nick :='';
Players[2].Active:=True;

Players[3].Name :='';
Players[3].Pass :='';
Players[3].Nick :='';
Players[3].Active:=true;

Players[4].Name :='';
Players[4].Pass :='';
Players[4].Nick :='';
Players[4].Active:=true;

Players[5].Name :='';
Players[5].Pass :='';
Players[5].Nick :='';
Players[5].Active:=True;

Players[6].Name :='';
Players[6].Pass :='';
Players[6].Nick :='';
Players[6].Active:=True;

Writeln( IntToStr ( HowManyPlayers ) + ' Players' );
End;

var
CurLoad,MiningLvl,Bankers,ox,oy,Road,BankDtm,tc,Mining1,Mining2,OreMask:integer;
MineIron:boolean;
StartScriptMark:LongInt;

procedure MyNormRands;
var i:integer;
begin

FindTalk;


FindMime;

FindMaze;

FindQuiz;

FindDemon;

FindScapeRune;

FindLamp(LampSkill);
if (FindNewBox) then SolveBox;

if NoGameTab then
begin
//Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;

function IsNorth:boolean;
begin
Result:=(Getcolor(564, 9)=1911089) and (getcolor(568, 9)=1911089);
end;

procedure MakeNorth;
begin
if(IsNorth) then Exit;
KeyDown(VK_LEFT);
repeat
Wait(5);
until(IsNorth);
KeyUp(VK_LEFT);
wait(300+randoM(100));
end;

{function FindMiningSpot:boolean;
begin
writeln('Searching for mining spot...');
Result:= FindMMDtm(x,y,Road);
writeln('Done searching');
if(Result) then begin
x:=x-20;
y:=y+15;
end;
end; }

{procedure UpdateRoadColor;
var
CurTol:integer;
begin
if(FindMMColor(x,y,RoadColor)) then Exit;
CurTol:=0;
repeat
CurTol:=CurTol+1;
until(FindColorTolerance(x,y,RoadColor,MMCX-30,MMCY-30,MMCX+30,MMCY+30,CurTol));
RoadColor:=GetColor(x,y);
WriteLn('New RoadColor: '+inttostr(RoadColor));
end; }
procedure UpdateRoadColor;
var curtol:integer;
begin
repeat
curtol:=curtol+1;
until(FindbitmapTolerancein(Road,x,y,MMX1,MMY1,MMX2,MMY2,curtol));
RoadColor:=GetColor(x,y);
end;

procedure SetupPlayer;
begin
MakeNorth;
KeyDown(VK_UP);
wait(1200+random(500));
KeyUp(VK_UP);
SetChat('Off',1);
SetChat('Off',2);
SetChat('Off',3);
MiningLvl:=GetSkillLevel('Mining');
MineIron:=MiningLvl>=IronLevel;
if(not(FindMMDtm(x,y,Bankers))) then
Players[CurrentPlayer].loc:='Mine'
else
Players[CurrentPlayer].loc:='Bank';
FindPickHeadColor;
GameTab(4);
end;

procedure FindObjBank;
var Tries:integer;
begin
for Tries:=0 to 10 do begin
if(not(FindObjMultiText(x,y,'ooth','Bank','Use',606808,10))) then Exit;
Mouse(x,y,0,0,False);
wait(10+random(10));
ClickOption('Use-quickly',1);
Flag;
wait(800+random(200));
if(BankScreen) then Exit;
end;
end;

{function DtmBank:boolean;
begin
wait(400+random(100));
if(not(FindMSDtm(x,y,BankDtm))) then Exit;
MMouse(x,y,1,1);
wait(50+random(50));
if(IsUpText('ooth') or IsUpText('Use')) then Mouse(x,y,1,1,false);
wait(10+random(20));
Result:=ClickOption('Use-quickly',1);
if(Result) then begin
Flag;
wait(400+random(100));
end;
end; }



procedure Banking;
begin
FindObjBank;
BenMouse:=True;
if(not(EquipPick)) then Deposit(2,28,2) else Deposit(1,28,2);
BenMouse:=False;
Mouse(485, 41,2,2,true);
wait(50+random(50));
end;

procedure SetupScript;
begin
BenMouse:=False;
MouseSpeed:=20;
RoadColor:= 5921377;
Bankers:=DTMFromString('78DA636C626260886640017FFE3031F003694' +
'6289FB11DA18615979A6E22D44C26D29C04FC6A005C0D0ED4');
Road:= BitmapFromString(5, 5, 'z78DA337734373437321F6424007DD3' +
'2022');
//BankDtm:=DTMFromString('78DA635462646038C88002229C3819B880342' +
// '394CFA80C649D80B059A162137BBA31D55C43559390108AAA4605' +
// 'C8BA83AA06DD2E006E3F080E');
{Mining1:= DTMFromString('78DA634C646260F06740012C8C8C0C22409A1' +
'1CA67CC00AA0981B09971A94901AA09465553595E82AA06645728' +
'AA9AFA704D1435006F0005B2');
Mining2:= DTMFromString('78DA63AC666260486040012C8C8C0C22409A1' +
'1CA672C06AA8984B09971A92907AA894655531CA08CAAA616534D' +
'4A623C8A1A00825305D1'); }
OreMask := BitmapFromString(11, 11, 'z78DA73730301033070436' +
'2238B60024C35B84CC0A5923C13F0BB937813F0EB22DE04CC5022' +
'CF04CADD404CC890EA0BFCE2F85D4E4C6A212FF470998FCC0600F' +
'B599CC1');
LoadMiningBitMaps;
ActivateClient;
MarkTime(StartScriptMark);
end;

function FindMineRoadColor:boolean;
var cx,cy:integer;
begin
cx:=711;
cy:=MMCY;
repeat
cx:=cx-3;
until(FindColorTolerance(x,y,6381672,cx,cy-5,cx,cy+5,50));
Result:=True;
if(Result) then RoadColor:=GetColor(x,y);
end;

procedure FindBankRoadColor;
begin
FindMMDtm(x,y,Bankers);
RoadColor:=getcolor(x,y+7);
//WriteLn('RoadColor: '+inttostr(RoadColor));
end;

function WalkRoad(dir:string;dist:integer):boolean;
var
DistOut,rx,ry:integer;
begin
UpdateRoadColor;
DistOut:=3;
repeat
DistOut:=DistOut+1;
if(DistOut)=30 then Exit;
until FindColor(rx,ry,RoadColor,MMCX-DistOut,MMCY-DistOut,MMCX+DistOut,MMCY+DistOut);
if(dir='N') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=30) then Exit;
until FindColor(rx,ry,RoadColor,rx-DistOut,ry-DistOut,rx+DistOut,ry-1);
until(abs(ry-MMCY)>=dist);
end;
if(dir='S') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=30) then Exit;
until FindColor(rx,ry,RoadColor,rx-DistOut,ry+1,rx+DistOut,ry+DistOut);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
if(dir='E') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=30) then Exit;
until FindColor(rx,ry,RoadColor,rx+1,ry-DistOut,rx+DistOut,ry+DistOut);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
if(dir='W') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=30) then Exit;
until FindColor(rx,ry,RoadColor,rx-DistOut,ry-DistOut,rx-1,ry+DistOut);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
Mouse(rx,ry,1,1,true);
CountFlag(10);
Result:=True;
end;

procedure ToBank;
var
Step,CurRad:integer;
begin
if(not(FindMineRoadColor)) then begin
WriteLn('Can''t find raod color');
Logout;
Exit;
end;
CurRad:=10;
repeat
CurRad:=CurRad+3;
if(CurRad>90) then begin
Logout;
WriteLn('Error finding road');
Exit;
end;
until(RadialRoadWalk(RoadColor,10,110,CurRad,1,1))
for Step:=1 to 4 do begin
WalkRoad('N',60);
end;
Step:=0;
RadialRoadWalk(RoadColor,230,320,60,1,1);
repeat
Step:=Step+1;
WalkRoad('W',40);
if(Step=20) then begin
WriteLn('walking error');
Logout;
Exit;
end;
until(FindMMDtm(x,y,Bankers));
Mouse(x+5,y-5,3,1,true);
Flag;
end;

function FindMiningSpot:boolean;
begin
Result:=FindColorTolerance(x,y,74301,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,6578779,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,4021143,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,2709872,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,6646369,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,731994,MMX1,MMY1,MMX2,MMY2,5);
if(not(Result)) then Result:=FindColorTolerance(x,y,6314590,MMX1,MMY1,MMX2,MMY2,5);
end;

procedure ToMine;
var
Step,CurTol,sx,sy:integer;
begin
FindBankRoadColor;
RadialRoadWalk(RoadColor,10,90,60,1,1);
//UpdateRoadColor;
RadialRoadWalk(RoadColor,45,125,60,1,1);
//UpdateRoadColor;
RadialRoadWalk(RoadColor,90,180,60,1,1);
RadialRoadWalk(RoadColor,90,200,50,1,1);
Step:=0;
repeat
Step:=Step+1;
WalkRoad('S',40);
if(Step=30) then begin
WriteLn('Walking error');
Exit;
end;
Status(inttostr(Step));
until(FindMiningSpot and (Step>5));
Flag;
FindMiningSpot;
MouseFindFlag(x+3,y+3,3,-3);
Flag;
end;

procedure FindRandoms;
begin
if(FindFight) then begin
RunAwayDirection('W');
RunBack;
{Mouse(MMCX-70,MMCY,2,2,TRUE);
Flag;
Mouse(MMCX-70,MMCY,2,2,TRUE);
Flag;
wait(1000+random(100));
Mouse(MMCX+70,MMCY,2,2,True);
Flag;
Mouse(MMCX+70,MMCY,2,2,True);
Flag; }
wait(500+random(100));
end;
BenMouse:=True;
MyNormRands;
BenMouse:=False;
end;

function FindOre:boolean;
var
CurTol:integer;
begin
CurTol:=1;
repeat
ox:=MSCX;
oy:=MSCY;
//if(FindObjMultiText(ox,oy,'Mine','ock','Roc',OreColor,CurTol)) then begin
if(FindObjOre(ox,oy,'Rocks',OreColor,CurTol,3)) then begin
if(FindColorTolerance(x,y,OreColor,ox-2,oy-2,ox+2,oy+2,CurTol)) then begin
Result:=True;
Exit;
end;
end;
CurTol:=CurTol+1;
wait(200+random(200));
until(CurTol=5);
wait(300+random(200));
end;

function FindOre2:boolean;
begin
ox:=MMCX;
oy:=MMCY;
Result:=FindObjOre(ox,oy,'Rocks',OreColor,3,3);
end;



function GetOreColor:boolean;
var i:integer;
begin
if(MineIron) then OreColor:=IronColor else begin
case tc of
0: OreColor:=TinColor;
1: OreColor:=CopperColor;
end;
end;
repeat
i:=i+1;
wait(500);
if(i=20) then Logout;
until(FindOre or not(LoggedIn));
Result:=True;
OreColor:=GetColor(ox,oy);
WriteLn('OreColor: '+inttostr(OreColor));
end;

function MineFlag:boolean;
var
FlagBegin:LongInt;
begin
MarkTime(FlagBegin);
while(FlagPresent) do begin
Result:=true;
wait(1);
if(TimeFromMark(FlagBegin)>2000) then
Exit;
end;
end;

function CheckForGas:boolean;
begin
Result:=FindGas(ox,oy);// or FindGas(ox+8,oy+8) or FindGas(ox+8,oy-8) or FindGas(ox-8,oy-8) or FindGas(ox-8,oy+8);
end;

procedure MineOneRock;
var
StartMiningMark,Tries,CurOreCol:longint;
begin
for Tries:=1 to 50 do begin
//MMouse(ox,oy,1,1);
//wait(50+random(20));
//GetMousePos(x,y);
if(FindOre) then begin
CurOreCol:=GetColor(ox,oy);
if(CheckForGas) then begin
WriteLn('***Found Gas***');
Mouse(648, 83,2,2,true);
repeat
SleepAndMoveMouse(100);
until(Not(CheckForGas));
end;
Mouse(ox,oy,0,0,true);
if(MineFlag) then begin
wait(700+random(100));
Exit;
end;
//wait(600+random(100));
//FindOreColor;
MarkTime(StartMiningMark);
repeat
wait(50+random(50));
FindRandoms;
FindPick;
if(CheckForGas) then begin
Mouse(648, 83,2,2,true);
Exit;
end;
if(TimeFromMark(StartMiningMark)>6000) then begin
//WriteLn('Timeout');
Exit;
end;
until(not(FindColorTolerance(x,y,OreColor,ox-3,oy-3,ox+3,oy+3,3)));
Exit;
end;
if(not(FindMiningSpot)) then Logout;
wait(100);
FindRandoms;
if(Not(LoggedIn)) then Exit;
end;
Logout;
end;

Procedure Drop;

Begin
ClickAllItemsBmpMaskTolWait('rop', OreMask, 20, 25, 30+Random(30));
End;


procedure FillInv;
begin
if(not(MineIron)) then begin
if(tc=0) then tc:=1 else tc:=0;
end;
GetOreColor;
repeat
MineOneRock;
FindRandoms;
until(Not(LoggedIn)) or InventoryFull;
end;

begin
SetupSRL;
SetupScript;
DeclarePlayers;
repeat
LoginPlayer;
SetupPlayer;
for CurLoad:=1 to LoadsPerPlayer do begin
if(Players[CurrentPlayer].loc='Bank') then ToMine;
Players[CurrentPlayer].loc:='Mine';
if(not(FindMiningSpot)) then WriteLn('Error:cant find mining spot');
SetRun(True);
GameTab(4);
FillInv;
if(not(LoggedIn)) then Break;
if((DropTinCopper and not(MineIron)) or (DropIron and MineIron)) then begin
Drop;
end else begin
ToBank;
Players[CurrentPlayer].loc:='Bank';
if(not(LoggedIn)) then Break;
Banking;
end;
end;
if(LoggedIn) then NextPlayer(True) else NextPlayer(False);

until(False);
end.

Hey321

2007-02-11 17:36:32

Looks pretty good :P. I'm gonna test it as i need tons of ores for smithing on my skiller :).

Edit:

Well, only two problems are the fact that mining clicks WAY to fast. Like it goes

click ore
wait .1 of a second
click ore
etc.

Second is the walking to the mine.

cygo

2007-02-18 02:56:39

works from bank, goes south, and just follows the road to almost al kharid desert, and then 'Walking error' and 'Error:cant find mining spot'