SRL Archive - OSR Help

Walking to Exact Position


johnbrown8976

2012-04-19 20:44:18

Hi,
I use SPS_Walk for walking, it is almost accurate but does not get you to the exact tile. So I added a procedure which will click on the Main Screen to get to the exact tile. I was wondering if the clicking on the Main Screen for walking is safe enough or will it get banned. Here is my code:


Procedure walkToExactTile(originalPos: TPoint);
var
currentPos: TPoint;
east, west, north, south: Array of Integer;
dx, dy : Integer;
begin
east := [20, 10]; //first integer: distance from MSCX, second: Random
west := [20, 10];
north := [10, 10];
south := [40, 10];

SPS_Setup(RUNESCAPE_SURFACE, ['4_12']); //Could be any location

if SPS_WalkToPos(originalPos) then
writeln('SPS walk successful.')
else
begin
writeln('SPS walk failed');
exit;
end;
wait(1000);

currentPos := SPS_GetMyPos;
if currentpos=originalPos then
exit;

dx := currentPos.x-originalPos.x;
dy := currentPos.y-originalPos.y;

if dx<0 then
begin
writeln('Move east 1 tile');
Mouse(MSCX+east[0]+random(east[1]), MSCY, 0, 5, mouse_Right);
ChooseOption('alk here');
end
else if dx>0 then
begin
writeln('Move west 1 tile');
Mouse(MSCX-(west[0]+random(west[1])), MSCY, 0, 5, mouse_Right);
ChooseOption('alk here');
end;
wait(3000);

if dy>0 then
begin
writeln('Move north 1 tile');
Mouse(MSCX, MSCY-(north[0]+random(north[1])), 5, 0, mouse_Right);
ChooseOption('alk here');
end
else if dy<0 then
begin
writeln('Move south 1 tile');
Mouse(MSCX, MSCY+(south[0]+random(south[1])), 5, 0, mouse_Right);
ChooseOption('alk here');
end;
end;

NKN

2012-04-19 21:57:22

That's good, I might have to use that, if you'd let me.

As long as the mouse is randomized, it won't be a problem.

johnbrown8976

2012-04-19 22:45:19

From: NKN
That's good, I might have to use that, if you'd let me.

As long as the mouse is randomized, it won't be a problem.


Yup, feel free to use it. It works better on flat surfaces, works most of the time, sometimes failed in my experiments. But, I am still not able to make it move diagonal, I have to go one step at a time. If you get to try the script, and make it move diagonal, I would appreciate it.

nickrules

2012-04-19 22:53:12

In this case, it seems like it'd be fine, aside from it assuming you're withing one tile of the destination.

johnbrown8976

2012-04-20 01:22:04

From: nickrules
In this case, it seems like it'd be fine, aside from it assuming you're withing one tile of the destination.


In all my trials, about 100, I was one tile (left, right, top, bottom or diagonal) away from the destination tile. I could use a while loop to move the character until it reaches the destination, if it is more than a tile away from the destination.

I cannot move the character More Than One Tile At Once because the distance between more than one tiles is never constant: Slight slope or curves in the Main Screen Map will cause huge difference in distance.

NKN

2012-04-20 14:19:08

Helps my scripts a lot, where I need to be within a few tiles of said position, or finding the items fails.