From: Frt
function WalkPath(Tiles: TPointArray): Boolean;
var
I: Integer;
Path: TPointArray;
begin
Path := Tiles;
for i := 0 to High(Path) do
begin
if not WalkToTile(Path[i], 1, 0) then
WalkToTile(Path[i + 1], 1, 0);
end;
Wait(500 + Random(300));
end;
Add that function before the WalkToSmelter function.
Your script will look like:
program Smither;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}
{.include srl/srl/skill/smithing.scar}
function LoadPath: TPointArray;
begin
SetLength(Result, 2);
Result[0] := Point(3276, 3173);
Result[1] := Point(3275, 3186);
end;
function WalkPath(Tiles: TPointArray): Boolean;
var
I: Integer;
Path: TPointArray;
begin
Path := Tiles;
for i := 0 to High(Path) do
begin
if not WalkToTile(Path[i], 1, 0) then
WalkToTile(Path[i + 1], 1, 0);
end;
Wait(500 + Random(300));
end;
function WalkToSmelter: boolean;
begin
Result := WalkPath(LoadPath);
end;
begin
SetupSRL;
WalkToSmelter;
end.
Here is mine:
function FindMeOnPath(var Index: integer; Path: TPointArray; MaxDist: integer): boolean;
var
I, H, DistC, DistS, T : integer;
P : TPoint;
begin
Debug('FindMeOnPath', '');
T := GetTimeRunning;
H := High(Path);
P := GetMyPos;
DistS := Distance(P.x, P.y, Path[0].x, Path[0].y);
for I := 0 to H do
begin
DistC := Distance(P.x, P.y, Path[I].x, Path[I].y);
if DistC <= DistS then
begin
DistS := DistC;
Index := I;
end;
end;
Result := DistS <= MaxDist;
if not Result then Index := -1;
Debug('FindMeOnPath', 'Index = ' + IntToStr(Index) + ' Time: ' + IntToStr(GetTimeRunning - T) + ' ms');
end;
// Metagen
//Returns in a TPoint:
//x as: The tile the player is closest to
//y as: The last tile in the array that can be sequentially seen.
Function TileRange(TPA : TPointArray) : TPoint;
var
I, H : Integer;
begin
if not FindMeOnPath(result.x, TPA, 20) then
Exit;
H := high(TPA)
for i := result.x to H do
begin
if not TileOnMM(TPA[i]) then
begin
if i = Result.x then
begin
Debug('TileRange', 'Could Not Find The Path');
Exit;
end;
result.y := Max(i-1, Result.x);
Debug('TileRange', 'TileRange is: ' + inttostr(result.x) + ', ' + IntToStr(result.y));
exit;
end;
end;
Debug('TileRange', 'Can See All Remaining Tiles');
result.y := High(TPA);
Debug('TileRange', 'TileRange is: ' + inttostr(result.x) + ', ' + IntToStr(result.y));
end;
// Metagen
// Picks a good human-like next Tile in the array to walk to and returns
// the array index
Function GenNextTile(TPA : TPointArray) : Integer;
var
PathRange : TPoint;
Variance : Integer;
begin
PathRange := TileRange(TPA);
Variance := (PathRange.y - PathRange.x) / 4;
Result := PathRange.y - Variance - Random(Variance);
Debug('GenNextTile', 'Next Path Tile: ' + IntToStr(Result));
end;
// Metagen / Nava2
function WalkPath(Path: TPointArray) : Boolean;
var
I, H : Integer;
NextTile : Integer;
begin
if not R_LoggedIn then Exit;
Debug('WalkPath', 'Walking the Path.');
H := High(Path);
for I := 0 to H do
begin
if NextTile >= I then Continue;
NextTile := GenNextTile(Path);
if not WebWalk(Path[NextTile]) then
begin
SRL_Warn('WalkPath', 'Could not make it to Path[' + IntToStr(I) + ']', Warn_AllVersions);
Exit;
end;
WaitWhileMoving(Path[NextTile], 8, false);
end;
R_Flag;
Result := DistanceFrom(Path[H]) < 5;
end;
From: ~~Joker~~
and, hopefully you have downloaded Reflection.
He wouldn't have WalkToTile if he didn't.