PDA

View Full Version : [Committed] WindWalk



Shuttleu
12-29-2011, 11:16 PM
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
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

Hero
12-30-2011, 01:49 AM
Nice. It is a little weird but that might just be the area I am in. The point I set is a straight shot but it runs at a V type movement on the map.

Shuttleu
12-30-2011, 09:30 AM
you have to make sure you have loaded the correct map, assuming you have, where are you trying it

~shut

EDIT: 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.

Hero
12-30-2011, 10:58 PM
I was messing around in Varrock(yes I know the snow was probably the issue). Works great though. I set up a walker from Seers Bank to the maple tree using cases and randomization since it is just the 1 click(yes I know I could use other methods but why not use the up and coming WindWalk) :)

Gushers
01-02-2012, 12:37 AM
I did everything and when I tried to compile I got this: "Unknown identifier 'MMCX' at line 135.. Compiling failed."
For this code(even though I didn't mess with it) :
/ Gets the map pieces that appear on the minimap
function SPS_GatherMinimap: T3DIntegerArray;
var
bmp: TMufasaBitmap;
c: TClient;
begin
try
bmp := TMufasaBitmap.Create;
bmp.SetSize(100, 100);

c := getTClient;
bmp.CopyClientToBitmap(
c.IOManager, false, 0,0, MMCX-50, MMCY-50, MMCX+50, MMCY+50 //FROM HERE
); // TO HERE

Result := SPS_BitmapToMap(bmp);
finally
bmp.free;
except
SPS_DebugStr('[ERROR] in SPS_GatherMinimap: '+ExceptionToString(ExceptionType, ExceptionParam));
SPS_WarnUser('SPS_GatherMinimap', ExceptionToString(ExceptionType, ExceptionParam));
end;
end;

And you said "So i also propose there is a SPS_WalkToPosEx which would be like so ... and than the code"
And I don't have a SPS_WalkToPosEx.

Shuttleu
01-02-2012, 12:39 AM
dont know what you done, but you broke it

*sigh*
just replace it with this one

~shut

Gushers
01-02-2012, 12:45 AM
Okay I replaced your whole SPS with mine... And I got the same error. This is weird.

Shuttleu
01-02-2012, 12:46 AM
have you included SRL before SPS?

~shut

Gushers
01-02-2012, 12:49 AM
I dont understand.. Explain a bit more?

Shuttleu
01-02-2012, 12:50 AM
the script that your using it with, is SRL includes BEFORE SPS

~shut

Gushers
01-02-2012, 01:01 AM
My scripts compile just fine.. I'm just trying to compile SPS.simba itself (the file you sent me) do I need to compile it? Or just save it?

Shuttleu
01-02-2012, 01:13 AM
you just save it in C:/Simba/Includes/SPS

its a include file not a script
you use it in a script

~shut

Gushers
01-02-2012, 01:22 AM
Alright man well now it's time to say THANK YOU! This works amazing.
I'm now making a script to help out our community.
Only question is how do I find the RuneScape Surface numbers I need?
Do I use the PathCreator v0.9 for SPS?

Shuttleu
01-02-2012, 01:44 AM
Alright man well now it's time to say THANK YOU! This works amazing.
I'm now making a script to help out our community.
Only question is how do I find the RuneScape Surface numbers I need?
Do I use the PathCreator v0.9 for SPS?

i always found those numbers to be wrong

best way is to open C:/Simba/Includes/SPS/img and find the images that you want to use, then put their names in the script below and press play, it will spit out a co-ordinate you can use


{$loadlib sps}
{$i srl/srl.scar}
{$i sps/sps.simba}

begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['7_7', '7_8']);
Writeln(SPS_GetMyPos);
end.

~shut

Gushers
01-02-2012, 02:29 AM
Alright thanks again man! This is amazing.

P1nky
01-04-2012, 10:36 AM
Question: if I will release my script to Public and it is going to be using 'Windwalk' would everyone need to make these changes, cause I doubt SRL has added this to SPS?

Shuttleu
01-04-2012, 10:38 AM
yes, or until it gets added you can add these functions to your script

~shut

marpis
01-04-2012, 10:59 AM
Thanks! :-) I will release these with SPS2

exilednoob
02-07-2012, 08:02 AM
Hey everyone, Im new to all of this, but I'm learning quickly

So how do I add this to my SPS file?
Do I open up the SPS and replace some of the current coding with this new coding?
If do, which part of the SPS code do i replace?
If I am wrong could you please help?

Coh3n
03-25-2012, 11:58 PM
This has been added to my SPS2.0 branch. I'll be updating marpis's 1.5 thread later.

E: Here's the modified version of SPS_WindWalk that I added. From what I tested, it's quite a bit faster than the one you posted Shut. Not exactly sure why, but it works great. :)

// Walks from the player's current position to the point T
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;

Result := SPS_WalkPath(ctrlPoints);
until(Result);
end;