Swag Bag
07-14-2015, 10:28 PM
Over my vacation I took Ross; walking procedure https://villavu.com/forum/showthread.php?t=113404 and looked at it some more. My problem with it was that when walking to places the randomness would compound and I would end up further off track than I wanted. However without it I would click the same spots every time. I had a go at it and came up with a new approach. So here goes:
procedure tileWalkInterval(point : TPoint; r : Integer);
var
stepSize, rx, ry, toGoX, toGoY : Integer;
next : TPoint;
begin
stepSize := r + 7;
toGoX := point.X;
toGoY := point.Y;
repeat
rx := random(-r, r);
ry := random(-r, r);
next := [sgn(toGoX) * (min(abs(toGoX), stepSize)) + rx, sgn(toGoY) * (min(abs(toGoY), stepSize)) + ry];
walkTo(next);
waitFlag();
toGoX := toGoX - next.X;
toGoY := toGoY - next.Y;
until (abs(toGoX) <= r) and (abs(toGoY) <= r);
end;
This procedure is designed to walk a set of points or a long distance. It utilizes random numbers to walk different intervals and randomness for each point on the way. The way it works is it takes the point it is walking to and stores it in toGoX and toGoY. As it loops it subtracts what it has walked from toGoX and toGoY and repeats until it reaches its destination. If you plug in 0 for r it will be 100% accurate.
And the sgn function simply returns the sign of a number:
function sgn(x : Integer) : Integer;
begin
if x = 0 then
exit(0)
else
if x > 0 then
exit(1)
else
exit(-1);
end;
And here is the walkTo procedure I use:
procedure walkTo(point : TPoint);
begin
mouse.click(minimap.getScreenPosition(minimap.getL ocalPosition().adjustPosition(point.X, point.Y)), 1);
end;
Here is the waitFlag procedure Ross; wrote that goes with this:
procedure waitFlag;
begin
wait(250);
while (not ogl.getTextures(1275).isEmpty()) do
wait(500);
end;
And finally here is the tileWalk procedure that I modified. This is what you call in your program.
procedure tileWalk(r : Integer; points : TPointArray);
var
i : Integer;
next : TPoint;
begin
for i := 0 to high(points) do
begin
next := points[i];
tileWalkInterval(next, r);
end;
end;
As an example you would use this by calling the tileWalk procedure with your randomness and the array of Points (or point) to walk.
tileWalk(2, [[-3, -10], [-11, -10], [-25, -7], [-8, -16], [12, -12]]);
or you could do
tileWalk(5, [[100, 94]]);
I spent quite a bit of time brainstorming and optimizing the code for this so please let me know what you think about it and if there are any areas I can improve! Thanks again to Ross; for the original code and Clarity; for answering a couple questions.
(Here is my first go at writing the new procedure :D 26426)
procedure tileWalkInterval(point : TPoint; r : Integer);
var
stepSize, rx, ry, toGoX, toGoY : Integer;
next : TPoint;
begin
stepSize := r + 7;
toGoX := point.X;
toGoY := point.Y;
repeat
rx := random(-r, r);
ry := random(-r, r);
next := [sgn(toGoX) * (min(abs(toGoX), stepSize)) + rx, sgn(toGoY) * (min(abs(toGoY), stepSize)) + ry];
walkTo(next);
waitFlag();
toGoX := toGoX - next.X;
toGoY := toGoY - next.Y;
until (abs(toGoX) <= r) and (abs(toGoY) <= r);
end;
This procedure is designed to walk a set of points or a long distance. It utilizes random numbers to walk different intervals and randomness for each point on the way. The way it works is it takes the point it is walking to and stores it in toGoX and toGoY. As it loops it subtracts what it has walked from toGoX and toGoY and repeats until it reaches its destination. If you plug in 0 for r it will be 100% accurate.
And the sgn function simply returns the sign of a number:
function sgn(x : Integer) : Integer;
begin
if x = 0 then
exit(0)
else
if x > 0 then
exit(1)
else
exit(-1);
end;
And here is the walkTo procedure I use:
procedure walkTo(point : TPoint);
begin
mouse.click(minimap.getScreenPosition(minimap.getL ocalPosition().adjustPosition(point.X, point.Y)), 1);
end;
Here is the waitFlag procedure Ross; wrote that goes with this:
procedure waitFlag;
begin
wait(250);
while (not ogl.getTextures(1275).isEmpty()) do
wait(500);
end;
And finally here is the tileWalk procedure that I modified. This is what you call in your program.
procedure tileWalk(r : Integer; points : TPointArray);
var
i : Integer;
next : TPoint;
begin
for i := 0 to high(points) do
begin
next := points[i];
tileWalkInterval(next, r);
end;
end;
As an example you would use this by calling the tileWalk procedure with your randomness and the array of Points (or point) to walk.
tileWalk(2, [[-3, -10], [-11, -10], [-25, -7], [-8, -16], [12, -12]]);
or you could do
tileWalk(5, [[100, 94]]);
I spent quite a bit of time brainstorming and optimizing the code for this so please let me know what you think about it and if there are any areas I can improve! Thanks again to Ross; for the original code and Clarity; for answering a couple questions.
(Here is my first go at writing the new procedure :D 26426)