Log in

View Full Version : Is this correct? [ATPA]



Footy
08-14-2012, 02:09 PM
Just made my first TPA/ATPA function thanks to NKN's tut! It works pretty well, getting to the correct spot after ~2-3 mouse movements, ill just have to adjust the color to fix that, but I was wondering If I had formatted everything correctly, and if I did it how its supposed to be done.
program ATPATesting;
{$i srl/srl.simba}

var
x, y:integer;
Function FindBankCustom(var x, y:integer):boolean;
var
Sex, SeY, i, Counter:Integer;
BankTPA:TPointArray;
BankATPA : T2DPointArray;
begin
FindColorsSpiralTolerance(SeX, SeY, BankTPA, 4412773, MSX1, MSY1, MSX2 - 10, MSY2, 12);
BankATPA := SplitTPA(BankTPA, 8);
for i := 0 to high(BankATPA) do
begin
if MiddleTPAEX(BankATPA[i], SeX, SeY) then
Mmouse(SeX, SeY, 3, 3);
wait(randomrange(150, 400));
if IsUptextMultiCustom(['Bank Bank', 'Bank ban', 'ank Ban']) then
begin
writeln('Bank found!');
x := SeX;
y := SeY
Result := true;
Exit;
end;
end;



end;
begin
SetupSRL
FindBankCustom(x, y);
Clickmouse2(mouse_left);
end.

Brandon
08-14-2012, 02:18 PM
No. You need begins and ends before the MMouse and one to match respectively.

Also you may want to avoid some overhead.. you shouldn't do: for i := 0 to high(BankATPA) do

instead do: L := High(BankATPA) then do: for i := 0 to L do. That way the computer doesn't have to calculate what HighATPA is all the time.

The only exception to this should be when you can guarantee that the ATPA will be modified in some way (not constant).

Footy
08-14-2012, 02:21 PM
If I understood you correctly, this is what you mean?
program ATPATesting;
{$i srl/srl.simba}

var
x, y:integer;
Function FindBankCustom(var x, y:integer):boolean;
var
Sex, SeY, i, Counter:Integer;
BankTPA:TPointArray;
BankATPA : T2DPointArray;
begin
FindColorsSpiralTolerance(SeX, SeY, BankTPA, 4412773, MSX1, MSY1, MSX2 - 10, MSY2, 12);
BankATPA := SplitTPA(BankTPA, 8);
L := High(BankATPA)
for i := 0 to L do
begin
if MiddleTPAEX(BankATPA[i], SeX, SeY) then
begin
Mmouse(SeX, SeY, 3, 3);
wait(randomrange(150, 400));
if IsUptextMultiCustom(['Bank Bank', 'Bank ban', 'ank Ban']) then
begin
writeln('Bank found!');
x := SeX;
y := SeY
Result := true;
Exit;
end;
end;
end;



end;
begin
SetupSRL
FindBankCustom(x, y);
Clickmouse2(mouse_left);
end.

eska
08-14-2012, 02:31 PM
If I understood you correctly, this is what you mean?


Yep that's it.


You'll see, once you learn and understand TPA better, you'll want to use them for almost everything on the mainscreen.

Footy
08-14-2012, 02:34 PM
Already kind of falling in love with it! It makes finding objects on the MS sooo much easier!

J J
08-14-2012, 02:43 PM
Already kind of falling in love with it! It makes finding objects on the MS sooo much easier!
Yup :)

I would personally make some small changes:
function FindBank: Boolean;

var
X, Y, i, Counter: Integer;
BankTPA: TPointArray;
BankATPA: T2DPointArray;

begin
FindColorsSpiralTolerance(X, Y, BankTPA, 4412773, MSX1, MSY1, MSX2 - 10, MSY2, 12);
SplitTPAExWrap(BankTPA, width, height, BankATPA);
for i := 0 to High(BankATPA) do
begin
if (MiddleTPAEX(BankATPA[i], X, Y)) then
begin
MMouse(X, Y, RandomRange(-3, 3), RandomRange(-3, 3));
if (WaitUptextMulti(['ank', 'Bank']) then
begin
WriteLn('Bank found!');
Result := True;
Break;
end;
end;
end;
end;
Should compile. Good job so far :)

Footy
08-14-2012, 02:46 PM
Yup :)

I would personally make some small changes:
function FindBank: Boolean;

var
X, Y, i, Counter: Integer;
BankTPA: TPointArray;
BankATPA: T2DPointArray;

begin
FindColorsSpiralTolerance(X, Y, BankTPA, 4412773, MSX1, MSY1, MSX2 - 10, MSY2, 12);
SplitTPAExWrap(BankTPA, width, height, BankATPA);
for i := 0 to High(BankATPA) do
begin
if (MiddleTPAEX(BankATPA[i], X, Y)) then
begin
MMouse(X, Y, RandomRange(-3, 3), RandomRange(-3, 3));
if (WaitUptextMulti(['ank', 'Bank']) then
begin
WriteLn('Bank found!');
Result := True;
Break;
end;
end;
end;
end;
Should compile. Good job so far :)

What exactly does SplitTPAExWrap do? whats the difference between it and what i used? Thanks for the feedback everyone!

riwu
08-15-2012, 01:06 PM
What exactly does SplitTPAExWrap do? whats the difference between it and what i used? Thanks for the feedback everyone!
SplitTpa splits the point in a circular manner (with radius=Dist) while the Ex version does it in a box manner.