Floor66
2011-03-26 15:30:21
Needed this for a script. Thought I'd share it. Thought I'd post it here because it's 'Research' for scripts? If not, please move it.
Set the consts, log your player in, disable SMART, start the script and walk the path.
Once you stop the script, the path'll pop up in the debug box.
Will output something along the lines of…
Rate/Hate/Masturbate
Set the consts, log your player in, disable SMART, start the script and walk the path.
Once you stop the script, the path'll pop up in the debug box.
program PathRecorder;
//Credits: Floor66.
{$DEFINE SMART}
{$i SRL/SRL.scar}
{$i Reflection/Reflection.simba}
var
Path : TTileArray;
const
MinDist = 3; //Minimum distance to put inbetween steps.
MaxWait = 5; //Seconds to wait until terminating after not moving.
function HighEx(p : TTileArray): Integer;
var
i, l : Integer;
begin
l := High(p);
for i := 0 to l do
if p[i] = Point(-1, -1) then
begin
Result := i - 1;
Exit;
end;
end;
procedure PrintPath;
var
i, l : Integer;
s : String;
begin
l := HighEx(Path);
s := 'Path := [Tile('+ ToStr(Path[0].x) +', '+ ToStr(Path[0].y) +'), ';
for i := 1 to l do
begin
if Path[i] = Point(-1, -1) then
Break;
if (i mod 3) = 0 then
s := s + #13#10 +' ';
if i <> l then
s := s + 'Tile('+ ToStr(Path[i].x) +', '+ ToStr(Path[i].y) +'), '
else
s := s + 'Tile('+ ToStr(Path[i].x) +', '+ ToStr(Path[i].y) +')];';
end;
WriteLn(s);
end;
procedure RecordPath;
var
t : TPoint;
i, l, m : Integer;
moved : Boolean;
begin
SetLength(Path, 999);
l := High(Path);
for i := 0 to l do
Path[i] := Point(-1, -1);
i := 0;
t := GetMyPos;
repeat
moved := False;
if DistanceTile(t, GetMyPos) > MinDist then
begin
WriteLn('Added point ['+ ToStr(i) +'].');
Path[i] := GetMyPos;
Inc(i);
t := GetMyPos;
end;
if GetSpeed = 0 then
begin
WriteLn('Not moving.');
MarkTime(m);
while (TimeFromMark(m) < (MaxWait * 1000)) and (not moved) do
begin
moved := GetSpeed > 0;
Wait(10);
end;
if not moved then
begin
WriteLn('Stopping.');
Break;
end;
end;
until(False);
end;
begin
AddOnTerminate('PrintPath');
Smart_Signed := True;
Smart_Members := False;
Smart_Server := 152;
SetupSRL;
while GetSpeed = 0 do
Wait(10);
RecordPath;
end.Will output something along the lines of…
Path := [Tile(3089, 3230), Tile(3090, 3234), Tile(3088, 3238),
Tile(3087, 3242), Tile(3087, 3246), Tile(3091, 3247)];Rate/Hate/Masturbate