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.
↓ 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
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.↓ 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