SRL Archive - General Botting Help

ATPA question


Spaceblow

2014-08-08 21:20:31

So I'm making a simple script that collects redberries from a bush. I think I'm almost done but I can't figure out how to solve something. This is what I have so far (major thanks to The Mayor for his AIO guide):

procedure getRedberries();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
redberriesTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

redberriesTimer.start();

repeat

findColorsSpiralTolerance(x, y, TPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53));

if (Length(TPA) < 1) then
exit;

ATPA:= TPA.toATPA(30, 30);
ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
//smartImage.clear;
break;
end;
end;
tabBackpack.waitForShift(2000);

until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
end;

So it clicks the redberry bush and collects redberries. But the problem is there are only 2 redberries every bush, so I have to make it stop clicking after there aren't any left and continue to the next bush. I really don't know how to do that, it just keep clicking the bush while there aren't any redberries anymore. Maybe this could help you visualizing my problem:



And if I would finally make it work and it reaches the other bush and gets 2 redberries, do I have to use minimap.setAngle() to turn the camera so it could go to the other bush again or is there another/better way to do? Thanks in advance! :)

KeepBotting

2014-08-08 21:30:39

Tweak your for..to..do loop a bit.

 
for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
wait(randomRange(1000, 2000)); //however long it takes you to pick a berry
//may want to move the mouse a few random pixels here
fastClick(MOUSE_LEFT);
//smartImage.clear;
break;
end;
end;

In regards to your second question, I'd say just zoom all the way out and have the script keep your camera angle at wherever you can always see both bushes.

If that's not possible, you'd have to devise a function that checks which bush you're at, and turns a specific angle based on the result.

You could even even just bruteforce it by turning a random angle (or a specific angle that you know will always move the second bush into view) if no points are found.

The Mayor

2014-08-08 21:34:04

You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:



for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;

KeepBotting

2014-08-08 21:34:55

From: The Mayor
You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:



for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;

He knows how to click them,

he wants to click them twice is the problem.

This is good advice too, though.
Adding in a second color check will help improve accuracy.

For example: what if the script happens to move the mouse inside your ATPA box, but not directly on top of the redberry bush?
Then you'll get no mouseovertext and it'll think there's no bush there.

The Mayor

2014-08-08 21:38:10

From: KeepBotting
nono

he knows how to click them

he wants to click them twice is the problem


I think you will find my code picks red berries like a pro ;)

KeepBotting

2014-08-08 21:39:49

From: The Mayor
I think you will find my code picks red berries like a pro ;)

oh ofc

read my edit XD

Spaceblow

2014-08-11 18:59:10

Guys, I'm really sorry for the late reply. I'm pretty busy in real life and I hope you didn't think it was rude of me. :)

From: KeepBotting
Tweak your for..to..do loop a bit.

 
for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
wait(randomRange(1000, 2000)); //however long it takes you to pick a berry
//may want to move the mouse a few random pixels here
fastClick(MOUSE_LEFT);
//smartImage.clear;
break;
end;
end;

In regards to your second question, I'd say just zoom all the way out and have the script keep your camera angle at wherever you can always see both bushes.

If that's not possible, you'd have to devise a function that checks which bush you're at, and turns a specific angle based on the result.

You could even even just bruteforce it by turning a random angle (or a specific angle that you know will always move the second bush into view) if no points are found.
Thank you very much for your advice, I did what you suggested (turning a specific angle so both bushes would be on the mainScreen. :) But you probably interpreted my question wrongly. I was asking about the thing The Mayor answered. But instead you gave me a great tip about including wait(). Thanks! :)

From: The Mayor
You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:



for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;
That's the answer to my main question, I really appreciate the quick replies on this forum. Thanks! :)

This is what I have for this procedure. It's very basic stuff, no antibans yet:

 
procedure getRedberries();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
redberriesTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

redberriesTimer.start();
minimap.setAngle(320);
mainscreen.setZoom(true);
minimap.toggleRun(true);

repeat

findColorsSpiralTolerance(x, y, TPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
ATPA:= TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then

repeat

fastClick(MOUSE_LEFT);
wait(randomRange(650, 950));

until tabBackpack.waitForShift(5000);

smartImage.clear;
break;
end;
until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
end;

So, what do you think? :D

The Mayor

2014-08-11 19:21:35

From: Spaceblow
So, what do you think? :D


You didn't do what I said?

Spaceblow

2014-08-11 20:07:42

From: The Mayor
You didn't do what I said?
Wow I feel stupid now. I thought you meant I had to replace the bush colours with those from the redberries, so when you get the redberries and they disappear from the bush, the script goes for the other bush because there are redberries left. I probably was a little bit distracted when I was reading your message.

I edited it and now I have this:

procedure getRedberries();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
berryTPA: TPointArray;
redberriesTimer: TTimeMarker;


begin
if not isLoggedIn() then
exit;

redberriesTimer.start();
minimap.setAngle(320);
mainscreen.setZoom(true);
minimap.toggleRun(true);

repeat

findColorsSpiralTolerance(x, y, TPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53)); //bush colour
ATPA:= TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then

repeat

fastClick(MOUSE_LEFT);
wait(randomRange(650, 950));

until tabBackpack.waitForShift(5000);

smartImage.clear;
break;
end;
until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
end;

I changed this line (yours):
if findColorsSpiralTolerance(x, y, berryTPA(i), 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

Into this:
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

Because when I tried to use your line it said:
Exception in Script: Don't know which overloaded method to call with params (Int32, Int32, *unknown*, Int32, record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, record [0]Int32; [4]record [0]Extended; [10]Extended; [20]Extended; end; end) at line 144, column 12
Why is this happening?


I'm wondering about something though. When I test the procedure it goes to the first TPA, clicks to get the first redberries. Then it clicks to get the second redberries, now the bush is out of redberries and it's time to go to the other bush. But why does it just keeps clicking the same bush? Maybe the answer to that question is pretty obvious, but not to me. :(

The Mayor

2014-08-11 20:26:53

From: Spaceblow



I changed this line (yours):
if findColorsSpiralTolerance(x, y, berryTPA(i), 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

Into this:
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour



That wasn't my line :p (you must have added the (i) to the end of berryTPA, and deleted it from ATPA.getBounds).

From: Spaceblow

I'm wondering about something though. When I test the procedure it goes to the first TPA, clicks to get the first redberries. Then it clicks to get the second redberries, now the bush is out of redberries and it's time to go to the other bush. But why does it just keeps clicking the same bush? Maybe the answer to that question is pretty obvious, but not to me. :(


Yes, because you tell it to :p Since you removed the ATPA in the above line, it's not going to look at the individual bushes. Basically ATPA[0] is the first bush and ATPA[1] is the second bush. Also you added in another repeat loop which is a bad idea. What happens if there was no berries left you would keep clicking it for 6 sec waiting for the backpack count to change. Use the code exactly like I posted above.


procedure getRedberries();
var
x, y, i: integer;
bushTPA, berryTPA: TPointArray;
ATPA: T2DPointArray;
redberriesTimer: TTimeMarker;
begin
if not isLoggedIn() then
exit;

redberriesTimer.start();
minimap.setAngle(320);
mainscreen.setZoom(true);
minimap.toggleRun(true);

repeat

findColorsSpiralTolerance(x, y, bushTPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53));
ATPA:= TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
smartImage.clear;
break;
end;
end;

until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);

end;

Spaceblow

2014-08-12 07:48:10

From: The Mayor
That wasn't my line :p (you must have added the (i) to the end of berryTPA, and deleted it from ATPA.getBounds).
Wow haha, now I feel even more dumb. :p

From: The Mayor

Yes, because you tell it to :p Since you removed the ATPA in the above line, it's not going to look at the individual bushes. Basically ATPA[0] is the first bush and ATPA[1] is the second bush. Also you added in another repeat loop which is a bad idea. What happens if there was no berries left you would keep clicking it for 6 sec waiting for the backpack count to change. Use the code exactly like I posted above.
Alright, I did and now it's working pretty good. So the following procedure is what I have now. Is it a good idea to activate an antibot if it doesn't find the mouseovertext or not?

procedure getRedberries();
var
x, y, i: integer;
bushTPA: TPointArray;
berryTPA: TPointArray;
ATPA: T2DPointArray;
redberriesTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

redberriesTimer.start();
minimap.setAngle(320);
mainScreen.setAngle(MS_ANGLE_HIGH);

repeat

findColorsSpiralTolerance(x, y, bushTPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
ATPA:= bushTPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(1500 + random(1000));
writeLn('Succesfully got some redberries');
wait(randomRange(1250, 1500)); //waiting to refresh smartImage
smartImage.clear;
break;
end;
//end else 'ANTIBAN' (this is in case there's another player with the same colours, so it doesn't keep following it with the mouse and keep returning 'isMouseOverText(): False' (I experienced this while testing))
end;

until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
end;