Log in

View Full Version : SPS WalkPath(x)



DannyRS
11-23-2012, 04:22 PM
Hey i recently learned how to use a sps map to navigate the world, however this function seems to lock up the script untill it reaches its final destination point,

So my question is, is there a way to break the loop after an amount of time or a way to stop the function with some other code, im used to using C# OOP code where you can use some kind of co-routine or something to have two functions running at the same time,

Or maybe is there a SPS function that will walk along the path untill (x) happens,

In theory something like



While not (graveyardposition)
begin
SPS_WalkPath(destination)
end;


I need this for if the player dies while walking the path the script then takes a very long time for the sps walkpath to timeout,

Any help greately appreciated :) thanks

Hunaja
11-23-2012, 05:05 PM
Use edited version of SPS_WalkPath

function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T, D: integer;
P, MM: TPoint;
begin
H := High(Path);
T := GetSystemTime + 20000 + Random(5000);

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

P := SPS_GetMyPos;
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) or graveyard; <--- look here
end;
end;

litoris
11-23-2012, 05:07 PM
Instead of using WalkPath, use BlindWalk's between points that don't have any obstacles inbetween.
repeat
Wait(600);
until(SPS_BlindWalk(Point));

You could also put all the points in an array, then do this(much less troublesome for long paths):
for i=0 to High(PathArray) do
repeat
Wait(600);
until(SPS_BlindWalk(PathArray[i]));

PathArray has to be an array of points,determined by you, and i an integer obviously.
Could remove the wait, it's just there because that's what I do.

DannyRS
11-23-2012, 05:34 PM
ill give it a go thanks guys