SRL Archive - Senior Scripts and Snippets

[SMARTv2][WIP] Grand Exchange Miner


Smartzkid

2008-01-10 22:59:21

Nowhere near done, still have a ton of work to do, but I want it to be absolutely perfect when it's done. As efficient as possible. I'll try to keep the current version here; hopefully if I start to go wrong, someone will set me straight.

Still gotta add some more walking procedures.

program SMARTGEVEM; //Update #2
{.include SRL/SRL.scar}

var
VEMPath, GEPath: TPointArray;

Procedure DeclarePlayers;
begin
NumberOfPlayers(8);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Loc := 'Empty@VEB';

Players[1].Name :='';
Players[1].Pass :='';
Players[1].Nick :='';
Players[1].Active:=True;
Players[1].Loc := 'Empty@VEB';

Players[2].Name :='';
Players[2].Pass :='';
Players[2].Nick :='';
Players[2].Active:=True;
Players[2].Loc := 'Empty@VEB';

Players[3].Name :='';
Players[3].Pass :='';
Players[3].Nick :='';
Players[3].Active:=True;
Players[3].Loc := 'Empty@VEB';

Players[4].Name :='';
Players[4].Pass :='';
Players[4].Nick :='';
Players[4].Active:=True;
Players[4].Loc := 'Empty@VEB';
end;

procedure DeclarePaths;
begin
//For WalkToVEM/WalkToVEB
SetArrayLength(VEMPath,10);
VEMPath[0].X:=3254;
VEMPath[0].Y:=3426;
VEMPath[1].X:=3261;
VEMPath[1].Y:=3431;
VEMPath[2].X:=3273;
VEMPath[2].Y:=3430;
VEMPath[3].X:=3280;
VEMPath[3].Y:=3425;
VEMPath[4].X:=3285;
VEMPath[4].Y:=3416;
VEMPath[5].X:=3290;
VEMPath[5].Y:=3405;
VEMPath[6].X:=3291;
VEMPath[6].Y:=3395;
VEMPath[7].X:=3291;
VEMPath[7].Y:=3385;
VEMPath[8].X:=3289;
VEMPath[8].Y:=3376;
VEMPath[9].X:=3287;
VEMPath[9].Y:=3370;

//For WalkToGE/GEWalkToVEB


end;

//Returns CurrentPlayer
function cp: integer;
begin
result := CurrentPlayer;
end;

//Returns CurrentPlayer's loc
function cpl: string;
begin
result := Players[cp].loc;
end;

//Returns whether or not substr is in the current player's loc
function incpl(substr: string): boolean;
begin
result := Pos(substr, cpl) <> 0;
end;

function AtTile(Tile: TPoint; Tol: Integer): Boolean;
var
P: TPoint;
begin
P := GetMyPos;
Result := Distance(P.X, P.Y, Tile.X, Tile.Y) <= Tol;
end;

function WalkTile(Tile: TPoint; Randomness, FlagD: Integer): Boolean;
var
wTile: TPoint;
t: Integer;
begin
Randomize(Tile.X, Randomness);
Randomize(Tile.Y, Randomness);
TileToMiniMap(Tile, wTile.X, wTile.Y);

if not rs_OnMiniMap(wTile.X, wTile.Y) then
begin
Result := False;
Exit;
end;
Result := True;

MFNF(wTile.x, wTile.y, -1, -1);
t := getsystemtime;
FFlag(FlagD);
Result := (GetSystemTime - t) < 60000;
end;

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}

procedure WalkToVEM; //VEB->VEM
var
i: integer;
begin
for i := 0 to High(VEMPath) do
WalkTile(VEMPath[i], 3, 3);
Players[cp].loc := 'Empty@VEM';
end;

procedure WalkToVEB; //VEM->VEB
var
i: integer;
begin
for i := High(VEMPath) to 0 do
WalkTile(VEMPath[i], 3, 3);
Players[cp].loc := 'Full@VEB';
end;

procedure WalkToGE; //VEB->GE
var
i: integer;
begin
for i := 0 to High(GEPath) do
WalkTile(GEPath[i], 3, 3);
Players[cp].loc := 'Full@GE';
end;

procedure GEWalkToVEB; //GE->VEB
var
i: integer;
begin
for i := High(GEPath) to 0 do
WalkTile(GEPath[i], 3, 3);
Players[cp].loc := 'Empty@VEB';
end;

procedure BankAtVEB;
begin
WalkToVEB;
if(not(OpenBankQuiet('veb')))then
WalkTile(Point(0, 0), 3, 0); //Replace 0,0 with a tile right by the bankers
end;

procedure SellToGE;
begin

end;

procedure MineBestOre;
begin

end;

procedure MainLoop;
begin
repeat
if(InCPL('Empty'))then
begin
if(InCPL('VEB'))then
WalkToVEM;
if(InCPL('VEM'))then
MineBestOre;
if(InCPL('GE'))then
GEWalkToVEB;
end;
if(InCPL('Full'))then
begin
if(InCPL('VEM'))then
BankAtVEB;
if(InCPL('GE'))then
SellToGE;
end;
until(false)
end;

procedure RunOnce;
begin
SmartSetupEx(86, false, false);
SmartSetDebug(false);
SmartSetRefresh(17);
SetupSRL;
DeclarePlayers;
end;

begin
RunOnce;
MainLoop;
end.

&#8595; Will be added in final release, should this ever reach the level of absolute goodness that I want it to achieve.

Credit list (code):
-Wizzup, walking functions

Greets:
-Fawki & devs for SRL
-Benland, for SMART

Smartzkid

2008-01-11 16:22:33

I hope nobody minds me doubleposting in SSRL territory :p

Question: For the player locations, I'm using a InventoryState@Location. I was thinking about this, and I see that it could be quite inefficient in certain situations, because the inventory isn't checked every time the location is read. Would it be better to ditch the InventoryState and go with a check-as-needed approach?

Special Ed

2008-01-11 16:30:28

Yea I think so, because there isn't any reason that I can see for constantly knowing your inventory state.

I'll test it and maybe make something for it when I get a chance, but I'm going out of town this weekend so I won't be around.

Smartzkid

2008-01-12 10:21:04

Right now, I don't think it will even compile :p

I'll try to get it in working order asap, though.

EDIT: Updated, will compile now. I'll finish the walking when I'm done with my Spanish homework. Could be a couple hours.

The Claw

2008-01-12 20:53:27

sorry but i dont see the point in making it sell the ore to the GE between loads. why cut down precious autoing time walking back and forth the GE when we could just bank at VE? and then go sell to the GE manually after we have mined however many we want.

Smartzkid

2008-01-12 21:51:57

I'm lazy :p

It's only going to sell every X loads; every load would be a tad inefficient.

EDIT: Still being worked on, been busy for the last week and a while with midterms (middle of year testing) at school.