SRL Archive - SRL Positioning System

SPS walk timeout?


slushpuppy

2012-04-19 23:38:49

Please excuse me if this feature has already been included


Is there a way to implement a walk timeout for SPS? So if the character is stuck, SPS_walkpath does not follow an infinite loop of trying to walk to the next flag

tehq

2012-04-19 23:40:18

You mean like marking the time before and repeating until the time is greater than a certain number?

slushpuppy

2012-04-19 23:49:27

From: tehq
You mean like marking the time before and repeating until the time is greater than a certain number?


I doubt encapsulating a timeout in the loop will work because once SPS_walkpath is called, it does not return until it finishes walking the path- very deadly situation especially if your character is stuck

Caotom

2012-04-20 00:08:47

From: slushpuppy
I doubt encapsulating a timeout in the loop will work because once SPS_walkpath is called, it does not return until it finishes walking the path- very deadly situation especially if your character is stuck


Have you tried pasting the actual sps_walkpath function into your script, then calling it from your script (not the SPS Include) and manually implementing a timeout? (This is the quickfix that I used in a couple of my scripts).

~Caotom

slushpuppy

2012-04-20 00:18:19

From: Caotom
Have you tried pasting the actual sps_walkpath function into your script, then calling it from your script (not the SPS Include) and manually implementing a timeout? (This is the quickfix that I used in a couple of my scripts).

~Caotom


Thanks, I modified the SPS.simba directly, +1 for opensource :spot:. Would be nice if there was a SPS_setTimeOut() that would work for all SPS functions hehe

pencilbi

2012-04-20 04:06:47

i think its better to add a stuck detection in SPS_WalkPath.
so it return false stand for a stuck come.
use timeout to failsafe is not a good idea in my opinion.:)

Olly

2012-04-20 16:03:54

Would be nice to see, Since something like a gate could close on you and the script would be clicking on the minimap for years :P

shadowrecon

2012-04-20 16:26:38

There is already a timeout built into SPS_WalkPath .. it has a 25 second timeout, I think when it goes back after clicking the minimap it should compare the position that it got to the old position and if it didnt change then exit.


// Walks the path "Path"; always walks to the furthest point possible
function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T, D: integer;
P, MM,tempP: TPoint;
begin
tempP := Point(-1,-1);
H := High(Path);
T := GetSystemTime + 20000 + Random(5000);

while (not Result) and (GetSystemTime < T) do
begin
RunEnergy(20);

P := SPS_GetMyPos;

If tempP.X <> -1 then // check if player is stuck.
if InRange(tempP.X, (P.X - 10), (P.X + 10)) then
If InRange(tempP.Y, (P.Y - 10), (P.Y + 10)) then
Begin
Result := false;
Exit;
end;

tempP := P;

for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;

D := Distance(MM.X, MM.Y, MMCX, MMCY);

if (D < 10) then
break
else
if (D < 70) then
begin
if (SPS_MultiMouse) then
MultiMouse(MM.X, MM.Y, 25, 3, false)
else
Mouse(MM.X, MM.Y, 5, 5, mouse_Left);

FFlag(Integer(I <> H) * 15);

T := getSystemTime + 20000 + Random(1000);
Break;
end;
end;

Result := (I = H);
end;
end;

slushpuppy

2012-04-21 03:27:48

From: shadowrecon
There is already a timeout built into SPS_WalkPath .. it has a 25 second timeout, I think when it goes back after clicking the minimap it should compare the position that it got to the old position and if it didnt change then exit.


// Walks the path "Path"; always walks to the furthest point possible
function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T, D: integer;
P, MM,tempP: TPoint;
begin
tempP := Point(-1,-1);
H := High(Path);
T := GetSystemTime + 20000 + Random(5000);

while (not Result) and (GetSystemTime < T) do
begin
RunEnergy(20);

P := SPS_GetMyPos;

If tempP.X <> -1 then // check if player is stuck.
if InRange(tempP.X, (P.X - 10), (P.X + 10)) then
If InRange(tempP.Y, (P.Y - 10), (P.Y + 10)) then
Begin
Result := false;
Exit;
end;

tempP := P;

for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;

D := Distance(MM.X, MM.Y, MMCX, MMCY);

if (D < 10) then
break
else
if (D < 70) then
begin
if (SPS_MultiMouse) then
MultiMouse(MM.X, MM.Y, 25, 3, false)
else
Mouse(MM.X, MM.Y, 5, 5, mouse_Left);

FFlag(Integer(I <> H) * 15);

T := getSystemTime + 20000 + Random(1000);
Break;
end;
end;

Result := (I = H);
end;
end;


SPS_getmyPos isn't remarkably accurate, you would get differences +-2 even shortest periods between function calls. I don't really understand how checking a range of +-10 would determine if you are stuck

shadowrecon

2012-04-22 23:08:09

From: slushpuppy
SPS_getmyPos isn't remarkably accurate, you would get differences +-2 even shortest periods between function calls. I don't really understand how checking a range of +-10 would determine if you are stuck


It compares you current location to the location it previously had, and if its the same or withing a 10+- tolerance you would assume the character is stuck.