SRL Archive - Senior News and General

Pathfinder v2?


benleegt

2007-12-26 04:13:22

Now that we have tile based walking again I was wondering if someone of Benland could update the pathfinder to accomodate to the changes(GE and new wildy). Or perhaps a tutorial so we can learn and update it if necessary in the future or maybe even a loader(I don't know:S I don't know java). Perhaps it'd be good if it could reflect shared randoms and dungeons too :).

Wizzup?

2007-12-26 06:30:03

Hm. Or just walk the path once. With the Path Recorder in here:

program New;

{.include smart.scar}
{.include srl/srl.scar}


Var
WaterVials: LongInt;

Procedure DeclarePlayers;

Begin
NumberOfPlayers( 1 );
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Loc := 'Bank';

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

Function AtTile(Tile: TPoint; Dist: Integer): Boolean;

Var
P: TPoint;
Begin
GetMyPos(P.X, P.Y);
Result := Distance(P.X, P.Y, Tile.X, Tile.Y) <= Dist;
//writeln('Current Tile: (' + inttostr(p.x) + ', '+inttostr(p.y) + ')');
End;

Function WalkTile(Tile: TPoint; Disttol, Randomness: Integer): Boolean;

Var
wTile, P: TPoint;
d, degs: extended;
dist, t: integer;

Begin
Result := False;
Randomize(Tile.X, Randomness);
Randomize(Tile.Y, Randomness);

GetMyPos(P.X, P.Y);
Degs := rs_GetCompassAngleDegrees;
D := Degrees(ArcTan2(p.y - tile.y, p.x-tile.x)) - 90;
d := d - degs;
dist := Distance(MMCX, MMCY, p.x-tile.x + mmcx, p.y-tile.y + mmcy) * 4;
wTile.X := Round(MMCX + dist * Sin(D * pi / 180)) - 2;
wTile.Y := Round(MMCY + dist * Cos(D * pi / 180)) - 2;

If Not rs_OnMiniMap(wTile.X, wTile.Y) Then
Begin
WriteLn('Not in minimap');
WriteLn('('+inttostr(wtile.x)+','+inttostr(wtile.y)+')');
LogOut;
TerminateScript;
Exit;
End;
Result := True;
If AtTile(Tile, DistTol) Then
Begin
WriteLn('Already at tile');
Exit;
End;
MFNF(wtile.x, wtile.y, -1, -1);
t := getsystemtime;
While Not AtTile(Tile, DistTol) And ((getsystemtime - t) < 60000) Do
Wait(500);
Result := (GetSystemTime - t) < 60000;
If not result then
begin
LogOut;
TerminateScript;
end;
End;

Procedure RecordPath;

Var
I, x, y: Integer;
Begin
Repeat
Wait(500);
If IsFKeyDown(11) Then
Begin
GetMyPos(x, y);
WriteLn('TPA['+IntToStr(I) + '].X := ' + IntToStr(x)+';');
WriteLn('TPA['+IntToStr(I) + '].Y := ' + IntToStr(y)+';');
I := I + 1;
End;
Until IsFKeyDown(8);
End;

Function ShopKeeper: Boolean;

Var
x, y, t: Integer;

Begin
Result := False;
If FindObjTPA(x, y, 3235209, 9, 2, 5, 5, 5, 'Talk') Then
Begin
Mouse(x, y, 0, 0, False);
Wait(50);
If Not ChooseOption('rade') Then
Exit;
t := getsystemtime;
While Not (GetColor(161, 41) = 2070783) And (getsystemtime - t < 10000) Do
Wait(50);
If (GetSystemTime - t) >= 6000 Then
Exit;
Mouse(80, 120, 10, 10, False);
Wait(50);
If Not ChooseOption('Buy X') Then
Exit;
Wait(2000);
TypeSend(IntToStr(28+Random(100)));
Result := True;
End;
End;

{var
x, y: integer; }

Procedure ProgressReport;

Var
Sec, Rate: Integer;
Begin
Sec:= GetTimeRunning div 1000+1;
Rate:= 3600*WaterVials/Sec; // by mastaraymond.
WriteLn('----------------------------');
WriteLn('');
WriteLn('Wizzup Vial Buyer 0.01');
WriteLn('');
WriteLn('Worked for '+ TimeRunning);
WriteLn('WaterVials Banked : '+IntToStr(WaterVials));
WriteLn('Banking at a rate of ' + IntToStr(Rate) + ' WaterVials p/h.');
WriteLn('');
WriteLn('');
WriteLn('----------------------------');
SRLRandomsReport;
End;

Var
TPA: TPointArray;
p:tpoint;
i, t:integer;

begin
ClearDebug;
SmartSetup('ams5', false, false);
SetTargetDC(SmartGetDC);
setupsrl;
declareplayers;
loginplayer;
//RecordPath;
SetLength(TPA, 7);
TPA[0].X := 2615;
TPA[0].Y := 3332;
TPA[1].X := 2609;
TPA[1].Y := 3338;
TPA[2].X := 2608;
TPA[2].Y := 3328;
TPA[3].X := 2608;
TPA[3].Y := 3317;
TPA[4].X := 2607;
TPA[4].Y := 3308;
TPA[5].X := 2608;
TPA[5].Y := 3299;
TPA[6].X := 2614;
TPA[6].Y := 3296;
repeat
for i := low(tpa) to high(tpa) do
begin
GetMyPos(P.X, P.Y);
writeln('Walking tile number: ' + inttostr(i));
WalkTile(tpa[i], 3, 0);
end;

fflag(0);
wait(1500 + random(500));
t := getsystemtime;
repeat
wait(500);
findnormalrandoms;
if getsystemtime -t > 60000 then
break;
until shopkeeper;
findnormalrandoms;

if getsystemtime -t < 60000 then
WaterVials := WaterVials + 27;

for i := high(tpa) downto low(tpa) do
begin
GetMyPos(P.X, P.Y);
writeln('Walking tile number: ' + inttostr(i));
WalkTile(tpa[i], 3, 0);
end;
fflag(0);
wait(1500 + random(500));
colortolerancespeed(1);

openbankfast('db');

Deposit(2, 28, 2);
ProgressReport;
until false;
end.

BenLand100

2007-12-26 10:22:21

I could make a new map, but its really easy (actually) you just need to open the jagex world map (the one that you can drag) zoom in to 100%, move it to the top, left hand corner, and run this (assuming it still works from last summer ;)) Its not fast or efficient, but it works (I only needed to run it once ;))
program MapMaker;

procedure moveRight;
begin
movemouse(600,200);
wait(100);
holdmouse(600,200,true);
wait(100);
movemouse(1,200);
wait(100);
releasemouse(1,200,true);
wait(300);
end;

procedure moveDown;
begin
movemouse(350,430);
wait(100);
holdmouse(350,430,true);
wait(100);
movemouse(350,30);
wait(100);
releasemouse(350,30,true);
wait(300);
end;

procedure moveUp;
begin
movemouse(350,30);
wait(100);
holdmouse(350,30,true);
wait(100);
movemouse(350,430);
wait(100);
releasemouse(350,430,true);
wait(300);
end;

var
x, y: integer;
fullMap: integer;
mapCanvas: TCanvas;

procedure copyMapSquare;
begin
copyCanvas(GetClientCanvas, mapCanvas, 1, 30, 600, 430, x * 599, y * 400, x * 599 + 599, y * 400 + 400);
end;

//12 across
//16 down
begin
fullMap:= bitmapFromString(12 * 599, 15 * 400, '');
mapCanvas:= getBitmapCanvas(fullMap);
for x:= 0 to 11 do
begin
for y:= 0 to 14 do
begin
copyMapSquare;
moveDown;
end;
for y:= 0 to 14 do
begin
moveUp;
end;
moveRight;
end;
saveBitmap(fullMap, 'Map.bmp');
end.

nielsie95

2007-12-26 10:33:07


program BitmapBrowser;

const MapName = 'RsMap'; // Name of the bitmap you want to browse.
FormW = 600; // Width of the form.
FormH = 600; // Height of the form.

Xoff = 2382; // No need to change.
Yoff = 2216; // No need to change.

var
MainForm: TForm;
MapForm: TImage;
Button1, Button2: TButton;
Memo: TMemo;
ZoomLabel: TLabel;
MarkTCheck, LineTCheck, ZoomTCheck: TCheckBox;
ZoomScrollBar, WidthBar, HeightBar: TScrollBar;

var
Map, Width, Height, Counter: integer;
CurrentX1, CurrentY1, CurrentX2, CurrentY2: integer;
ZoomPick, MarkIt, Lines: Boolean;
Zoom: Extended;
MarkedSpots: TPointArray;

procedure LoadMap;
begin
Map := LoadBitmap(ScriptPath+MapName+'.bmp');
GetBitmapSize(Map, Width, Height);
end;

procedure FreeMap;
begin
FreeBitmap(Map);
end;

procedure SetSelfWindowState(State:TWindowState); //Yakman
begin
GetSelf.WindowState :=State;
end;

procedure SafeSetSelfWindowState(State:TWindowState); //Yakman
var
t: TVariantArray;
begin
t := [state];
ThreadSafeCall('SetSelfWindowState', t);
end;

procedure UpdateMap(PositionW, PositionH: integer);
begin
CurrentX1 := PositionW
if CurrentX1 < 0 then CurrentX1 := 0;
CurrentY1 := PositionH
if CurrentY1 < 0 then CurrentY1 := 0;

CurrentX2 := CurrentX1 + Round(FormW / Zoom);
CurrentY2 := CurrentY1 + Round(FormH / Zoom);

if CurrentX2 > Width then if Width > FormW then
begin
CurrentX1 := Width - Round(FormW / Zoom);
CurrentX2 := Width;
end;
if CurrentY2 > Height then if Height > FormH then
begin
CurrentY1 := Height - Round(FormH / Zoom);
CurrentY2 := Height;
end;
end;

procedure MarkLines;
var
x1, y1, x2, y2, i: integer;
begin
if GetArrayLength(MarkedSpots) < 1 then Exit;

MapForm.Canvas.Pen.Color := 255;
MapForm.Canvas.Pen.Width := 2;
for i := 1 to GetArrayLength(MarkedSpots) -1 do
begin
x1 := Round((MarkedSpots[i -1].x - CurrentX1) * Zoom);
y1 := Round((MarkedSpots[i -1].y - CurrentY1) * Zoom);
x2 := Round((MarkedSpots[i].x - CurrentX1) * Zoom);
y2 := Round((MarkedSpots[i].y - CurrentY1) * Zoom);
//WriteLn('x1: '+IntTostr(x1)+' y1: '+IntTostr(y1)+' x2: '+IntTostr(x2)+' y2: '+IntToStr(y2));
MapForm.Canvas.MoveTo(x1, y1);
MapForm.Canvas.LineTo(x2, y2);
end;
end;

procedure MarkSpots;
var
i, x1, y1, x2, y2: integer;
begin
MapForm.Canvas.Pen.Color := 255;
MapForm.Canvas.Pen.Width := 2;
for i := 0 to GetArrayLength(MarkedSpots) -1 do
begin
x1 := Round((MarkedSpots[i].x - CurrentX1) * Zoom);
y1 := Round((MarkedSpots[i].y - CurrentY1) * Zoom);
x2 := x1 + 3;
y2 := y1 + 3;
//WriteLn('x1: '+IntTostr(x1)+' y1: '+IntTostr(y1)+' x2: '+IntTostr(x2)+' y2: '+IntToStr(y2));
MapForm.Canvas.RecTangle(x1, y1, x2, y2);
end;
if Lines then MarkLines;
end;

procedure MarkSpotInArray(x, y: integer);
begin
SetArrayLength(MarkedSpots, GetArrayLength(MarkedSpots) +1);
MarkedSpots[GetArrayLength(MarkedSpots) -1].x := Round(x / Zoom) + CurrentX1 -5;
MarkedSpots[GetArrayLength(MarkedSpots) -1].y := Round(y / Zoom) + CurrentY1 -1;
end;

procedure OnScroll(sender: TObject);
begin
UpdateMap(WidthBar.Position, HeightBar.Position);
//WriteLn('CurrentX1: '+IntToStr(CurrentX1)+' CurrentY1: '+IntToStr(CurrentY1)+' CurrentX2: '+IntToStr(CurrentX2)+' CurrentY2: '+IntToStr(CurrentY2));
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;

procedure OnZoomPick(sender: TObject);
begin
if ZoomTCheck.Checked then ZoomPick := True else ZoomPick := False;
end;

procedure OnMarkPoints(sender: TObject);
begin
if MarkTCheck.Checked then MarkIt := True else MarkIt := False;
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;

procedure OnMakeLines(sender: TObject);
begin
if LineTCheck.Checked then
begin
Lines := True;
MarkTCheck.Checked := True;
MarkIt := True;
end else Lines := False;
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;

procedure SetZoom(sender: TObject);
begin
Zoom := ZoomScrollBar.Position div 10;
//WriteLn('Zoom: '+FloatToStr(Zoom));
UpdateMap(WidthBar.Position, HeightBar.Position);
ZoomLabel.Caption := 'Zoom : '+FloatToStr(Zoom);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;

procedure ClearLast(sender: TObject);
begin
Memo.Lines.Delete(Memo.Lines.Count -1);
Counter := Counter -1;
SetArrayLength(MarkedSpots, GetArrayLength(MarkedSpots) -1);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;

procedure Clear(sender: TObject);
begin
Memo.Lines.Clear;
Counter := 0;
SetArrayLength(MarkedSpots, 0);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;

procedure Click(sender: TObject);
var
x, y: integer; Temp: TColor; xx, yy: extended;
begin
if not FindWindowBySize(FormW +11, FormH +251) then WriteLn('Client not found, please restart.');
//FindWindow('Runescape TileFinder - by Nielsie95');
if ZoomPick then PickColor(Temp, x, y) else
GetMousePos(x, y);
MarkSpotInArray(x, y -30);
xx := (Abs(x) / Zoom) + CurrentX1 //+ (Xoff * Zoom);
xx := (xx * 2) div 4;
xx := xx + Xoff//(Xoff * Zoom)
x := Round(xx);
yy := ((Abs(y) -30) / Zoom) + CurrentY1 //+ (Yoff * Zoom);
yy := (yy * 2) div 4;
yy := yy + Yoff//(Yoff * Zoom)
y := Round(yy);
//WriteLn('['+IntTostr(Counter)+'] x: '+IntToStr(x)+' y: '+IntToStr(y)+' TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
//WriteLn('['+IntTostr(Counter)+'] TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
Memo.Lines.Add('['+IntTostr(Counter)+'] TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
Counter := Counter +1;
if MarkIt then MarkSpots;
end;

Procedure InitForm;
begin
MainForm := CreateForm;
MainForm.BorderIcons := [biSystemMenu, biMiniMize];
MainForm.Left := 1573;
MainForm.Top := 129;
MainForm.Width := FormW +10;
MainForm.Height := FormH +250;
MainForm.Caption := 'Runescape TileFinder - by Nielsie95';
MainForm.Color := clBtnFace;
MainForm.Font.Color := clWindowText;
MainForm.Font.Height := -11;
MainForm.Font.Name := 'Arial';
MainForm.Font.Style := [];
MainForm.Visible := False;
MainForm.PixelsPerInch := 96;
MainForm.Position := poScreenCenter;

MapForm := TImage.Create(MainForm);
MapForm.Parent := MainForm;
MapForm.Width := FormW;
MapForm.Height := FormH;
MapForm.Center := True;
MapForm.OnClick := @Click;

WidthBar := TScrollBar.Create(MainForm);
WidthBar.Parent := MainForm;
WidthBar.Top := FormH;
WidthBar.Width := FormW;
WidthBar.Height := 17;
WidthBar.Max := Width;
WidthBar.Position := Width / 2;
WidthBar.TabOrder := 8;
WidthBar.OnChange := @OnScroll;

HeightBar := TScrollBar.Create(MainForm);
HeightBar.Parent := MainForm;
HeightBar.Left := 0;
HeightBar.Top := FormH + 17;
HeightBar.Width := FormW;
HeightBar.Height := 17;
HeightBar.Max := Height;
HeightBar.Position := Height / 2;
HeightBar.TabOrder := 9;
HeightBar.OnChange := @OnScroll;

Memo := TMemo.Create(MainForm);
Memo.Parent := MainForm;
Memo.ScrollBars := ssBoth;
Memo.Left := FormW / 2 - 190;
Memo.Top := FormH + 60;
Memo.Width := 380;
Memo.Height := 100;
Memo.Lines.Add('Runescape TitleFinder - by Nielsie95');
Memo.Lines.Add(' ');
Memo.TabOrder := 10;

ZoomLabel := TLabel.Create(MainForm);
ZoomLabel.Parent := MainForm;
ZoomLabel.Left := FormW / 2 - 110;
ZoomLabel.Top := FormH + 180;
ZoomLabel.Width := 40;
ZoomLabel.Height := 17;
ZoomLabel.Caption := 'Zoom : 1';

ZoomScrollBar := TScrollBar.Create(MainForm);
ZoomScrollBar.Parent := MainForm;
ZoomScrollBar.Left := FormW / 2 -50;
ZoomScrollBar.Top := FormH + 178;
ZoomScrollBar.Width := 120;
ZoomScrollBar.Height := 17;
ZoomScrollBar.PageSize := 0;
ZoomScrollBar.Min := 1;
ZoomScrollBar.Max := 30;
ZoomScrollBar.Position := 10;
ZoomScrollBar.TabOrder := 8;
ZoomScrolLBar.OnChange := @SetZoom;

ZoomTCheck := TCheckBox.Create(MainForm);
ZoomTCheck.Parent := MainForm;
ZoomTCheck.Left := FormW / 2 - 285;
ZoomTCheck.Top := FormH + 65;
ZoomTCheck.Width := 97;
ZoomTCheck.Height := 17;
ZoomTCheck.Caption := 'ZoomPick';
ZoomTCheck.TabOrder := 11;
ZoomTCheck.OnClick := @OnZoomPick;

MarkTCheck := TCheckBox.Create(MainForm);
MarkTCheck.Parent := MainForm;
MarkTCheck.Left := FormW / 2 - 285;
MarkTCheck.Top := FormH + 95;
MarkTCheck.Width := 97;
MarkTCheck.Height := 17;
MarkTCheck.Caption := 'Mark Points';
MarkTCheck.TabOrder := 11;
MarkTCheck.OnClick := @OnMarkPoints;

LineTCheck := TCheckBox.Create(MainForm);
LineTCheck.Parent := MainForm;
LineTCheck.Left := FormW / 2 - 285;
LineTCheck.Top := FormH + 125;
LineTCheck.Width := 97;
LineTCheck.Height := 17;
LineTCheck.Caption := 'Make Route';
LineTCheck.TabOrder := 11;
LineTCheck.OnClick := @OnMakeLines;

Button1 := TButton.Create(MainForm);
Button1.Parent := MainForm;
Button1.Left := FormW / 2 + 207;
Button1.Top := FormH + 75;
Button1.Width := 78;
Button1.Height := 25;
Button1.Caption := 'Clear Debug';
Button1.Font.Color := clWindowText;
Button1.Font.Height := -11;
Button1.Font.Name := 'MS Sans Serif';
Button1.Font.Style := [];
Button1.ParentFont := False;
Button1.TabOrder := 8;
Button1.OnClick := @Clear;

Button2 := TButton.Create(MainForm);
Button2.Parent := MainForm;
Button2.Left := FormW / 2 + 207;
Button2.Top := FormH + 120;
Button2.Width := 78;
Button2.Height := 25;
Button2.Caption := 'Clear Last Line';
Button2.Font.Color := clWindowText;
Button2.Font.Height := -7;
Button2.Font.Name := 'MS Sans Serif';
Button2.Font.Style := [];
Button2.ParentFont := False;
Button2.TabOrder := 9;
Button2.OnClick := @ClearLast;

Zoom := 1;
UpdateMap(Width / 2, Height / 2);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
LoadMap;
SafeSetSelfWindowState(wsMinimized);
SafeInitForm;
SafeShowFormModal;
SafeSetSelfWindowState(wsNormal);
FreeForm(MainForm);
FreeMap;
end.

This is the SCAR version I created for KYAB some time ago.
Get the map from Ben's MapCreator and put it in the same map as this script.
Set the mapname and it might work :)

benleegt

2007-12-27 00:53:34

Benland's mapper still works! :)
Too bad I ran out of memory just before it could save the file :S