Shuttleu
2011-12-29 18:16:34
Hello, i have finished the wind walking for SPS
This (as you would probably expect) creates a blind path and then walks along it in SPS.
I have tried this and i seems to work quite well
However because of the current SPS_WalkToPos being somewhat, slow… i have had to edit the include.
This is the function, it was mainly taken from Reflection, so i take no credit here other than getting the correct values for it to work
But as i said, i had to edit SPS_WalkToPos
So i also propose there is a SPS_WalkToPosEx which would be like so
However to keep things tidy i suggest that SPS_WalkToPos gets changed to the following
Here is a small script which you can use to test it
this one will walk from Catherby bank to the fishing spots
and this one will walk from the fishing spots to the bank
~shut
This (as you would probably expect) creates a blind path and then walks along it in SPS.
I have tried this and i seems to work quite well
However because of the current SPS_WalkToPos being somewhat, slow… i have had to edit the include.
This is the function, it was mainly taken from Reflection, so i take no credit here other than getting the correct values for it to work
function sps_WindPath(xs, ys, xe, ye, gravity, wind, maxStep, targetArea: extended): TPointArray;
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 5) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 5) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 15) then
begin
maxStep:= random(15) + 15;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) / 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[ High(Result) ] := Point(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
lastdist:= dist;
end;
end;
function sps_WindWalk(T: TPoint): Boolean;
var
I, Tries: Integer;
M, P: TPoint;
CTRLPoints: TPointArray;
begin
P := T;
repeat
M := SPS_GetMyPos;
if Length(CtrlPoints)=0 then
CtrlPoints := sps_WindPath(M.x, M.y, P.X, P.Y, 22.5, 12.5, 40, 20);
Inc(Tries);
if(Tries > 20)then
Exit;
for I:= High(CtrlPoints) downto 0 do
if sps_WalkToPosEx(CtrlPoints[i], 20) then
begin
Result := I = High(CtrlPoints);
Break;
end;
until(Result);
end;
But as i said, i had to edit SPS_WalkToPos
So i also propose there is a SPS_WalkToPosEx which would be like so
function SPS_WalkToPosEx(P: TPoint; FlagDist: Integer): boolean;
var
MM: TPoint;
begin
if not LoggedIn then Exit;
MM := SPS_PosToMM(P);
if (MM.X > 0) then
begin
Mouse(MM.X, MM.Y, 0, 0, True);
Wait(200+Random(300));
FFlag(FlagDist);
Result := True;
end;
end; However to keep things tidy i suggest that SPS_WalkToPos gets changed to the following
function SPS_WalkToPos(P: TPoint): boolean;
begin
result:= SPS_WalkToPosEx(p, 0);
end; Here is a small script which you can use to test it
this one will walk from Catherby bank to the fishing spots
program new;
{$loadlib sps}
{$i srl/srl.scar}
{$i sps/sps.simba}
begin
SetupSrl;
SPS_Setup(RUNESCAPE_SURFACE, ['7_7']);
sps_WindWalk(Point(3210, 2925));
end.and this one will walk from the fishing spots to the bank
program new;
{$loadlib sps}
{$i srl/srl.scar}
{$i sps/sps.simba}
begin
SetupSrl;
SPS_Setup(RUNESCAPE_SURFACE, ['7_7']);
sps_WindWalk(Point(3070, 2890));
end.~shut