SRL Archive - OSR Help

PreciseTPA DepositBox Clicking.


Sjoe

2013-02-10 18:22:10

As you see in the picture below
A lot of TPA's, and I tried to narrow them down, but the Deposit color isn't unique enough.
It even highlight the bankers :p

What I was wondering is how I could get my ATPA to only click on the depositbox, since it will hover 2 times now, bankers then the desk on my right side.

Since I'm not always ending in that exact position. I'm not only searching for the left side. This is for learning purposes too, for further causes. So I would know how to filter the objects I don't need.




function OpenDepositBoxCustom:Boolean;
var
TooLong, x, y, i, H, CTS :Integer;
TPA: TpointArray;
ATPA: T2DPointArray;

begin

if Depositscreen then
begin
Result := True;
Exit;
end;

Marktime(Toolong)

CTS := GetToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.48,0.08);

if FindColorsTolerance(TPA, 6381925, MSX1, MSY1, MSX2, MSY2, 12) then
begin

SetColorToleranceSpeed(CTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);

SplitTPAExWrap(TPA, 20, 20, ATPA);
SortATPAFromMidPoint(ATPA, Point(MSCX, MSCY));
SortATPASize(ATPA, True);
// Smart_DebugATPA(True, ATPA);

H := High(ATPA)

begin
for i:=0 to H do
begin
MiddleTpaEx(ATPA[i], x, y);
HumanMMouse(x, y, 10, 10)
if WaitUptextMulti(['Dep','pos', 'box'] , 800) then
begin
Fastclick(True);
if WaitFunc(@DepositScreen, 100, 3000) then
begin
Result :=True;
Exit;
end;
end;
end;
end;
end;
end;

Olly

2013-02-10 19:13:19

I edited the one i put in the includes, all i did was change the 2 colours :)

(*
OpenDepositBox
~~~~~~~~~~~~~~

.. code-block:: pascal

function OpenDepositBox : Boolean;

Opens the light deposit box (such as the boxes in edgeville).

.. note::

Author: Ollybest

Example:

.. code-block:: pascal

if (OpenDepositBox) then
DepositAll;
*)
function OpenDepositBox: Boolean;
var
i, CTS, c, Timeout: Integer;
TPA, TPA1, TPA2: TPointArray;
ATPA: T2DPointArray;
P: TPoint;
begin
Result := (DepositScreen);
if not (LoggedIn) or (Result) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
Timeout := 5000 + Random(1000);

// getting the dark edge
SetColorSpeed2Modifiers(0.06, 0.27);
FindColorsTolerance(TPA1, 1002342, MSX1, MSY1, MSX2, MSY2, 4);
// getting the light middle
SetColorSpeed2Modifiers(0.53, 0.57);
FindColorsTolerance(TPA2, 6184802, MSX1, MSY1, MSX2, MSY2, 8);

SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);

// combining and sorting
CombineTPAWrap(TPA1, TPA2, TPA);
SplitTPAWrap(TPA, 5, ATPA);
SortATPASize(ATPA, True);

if Length(TPA) < 1 then
Exit;

for i := 0 to High(ATPA) do
if Length(ATPA[i]) > 30 then
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.X, P.Y, RandomRange( -5, 5), RandomRange( -5, 5));
if WaitUpTextMulti(['Deposit Bank', 'deposit box', 'osit bo', 'eposit '], 400 + Random(100)) then
begin
ClickMouse2(True);
Flag;
MarkTime(c);
repeat
Wait(RandomRange(50, 100));
until (DepositScreen) or (PinScreen) or (TimeFromMark(C) > Timeout);
Result := (DepositScreen) or (PinScreen);
if (Result) then
Exit;
end;
end;
end;

Sjoe

2013-02-10 19:33:10

From: Ollybest
I edited the one i put in the includes, all i did was change the 2 colours :)

(*
OpenDepositBox
~~~~~~~~~~~~~~

.. code-block:: pascal

function OpenDepositBox : Boolean;

Opens the light deposit box (such as the boxes in edgeville).

.. note::

Author: Ollybest

Example:

.. code-block:: pascal

if (OpenDepositBox) then
DepositAll;
*)
function OpenDepositBox: Boolean;
var
i, CTS, c, Timeout: Integer;
TPA, TPA1, TPA2: TPointArray;
ATPA: T2DPointArray;
P: TPoint;
begin
Result := (DepositScreen);
if not (LoggedIn) or (Result) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
Timeout := 5000 + Random(1000);

// getting the dark edge
SetColorSpeed2Modifiers(0.06, 0.27);
FindColorsTolerance(TPA1, 1002342, MSX1, MSY1, MSX2, MSY2, 4);
// getting the light middle
SetColorSpeed2Modifiers(0.53, 0.57);
FindColorsTolerance(TPA2, 6184802, MSX1, MSY1, MSX2, MSY2, 8);

SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);

// combining and sorting
CombineTPAWrap(TPA1, TPA2, TPA);
SplitTPAWrap(TPA, 5, ATPA);
SortATPASize(ATPA, True);

if Length(TPA) < 1 then
Exit;

for i := 0 to High(ATPA) do
if Length(ATPA[i]) > 30 then
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.X, P.Y, RandomRange( -5, 5), RandomRange( -5, 5));
if WaitUpTextMulti(['Deposit Bank', 'deposit box', 'osit bo', 'eposit '], 400 + Random(100)) then
begin
ClickMouse2(True);
Flag;
MarkTime(c);
repeat
Wait(RandomRange(50, 100));
until (DepositScreen) or (PinScreen) or (TimeFromMark(C) > Timeout);
Result := (DepositScreen) or (PinScreen);
if (Result) then
Exit;
end;
end;
end;


Thanks!!

Wardancer

2013-02-11 17:43:20

Something you can add to make your TPAs more accurate is minimum and maximum length/width/height. It's actually quite simple and remarkably effective. In your loop, you can add things like:

For length:


if (Length(ATPA[a]) < Obj.Length) then
Continue;

For width and height:


B := GetTPABounds(ATPA[a]);
if ((B.X2 - B.X1) < Obj.Width) or ((B.Y2 - B.Y1) < Obj.Height) then
Continue;
if Obj.MaxWidth > 0 then
If ((B.X2 - B.X1) > Obj.MaxWidth) then
Continue;

Etc.

I often find this method to be much more effective and time efficient than scrupulous colour picking.

Here is the info I use for bank booths and it works like a charm at the place I use it.:

with BankBooth do
begin
Col := 5008776;
Tol := 10;
Hue := 1.0;
Sat := 1.0;
Length := 100;
Width := 20;
Height := 5;
UpText := 'Bank'
end;

As you can see, I really didn't make -any- effort with tol, hue and sat. It's a time saver, really.

Sjoe

2013-02-11 18:40:25

From: Wardancer
Something you can add to make your TPAs more accurate is minimum and maximum length/width/height. It's actually quite simple and remarkably effective. In your loop, you can add things like:

For length:


if (Length(ATPA[a]) < Obj.Length) then
Continue;

For width and height:


B := GetTPABounds(ATPA[a]);
if ((B.X2 - B.X1) < Obj.Width) or ((B.Y2 - B.Y1) < Obj.Height) then
Continue;
if Obj.MaxWidth > 0 then
If ((B.X2 - B.X1) > Obj.MaxWidth) then
Continue;

Etc.

I often find this method to be much more effective and time efficient than scrupulous colour picking.

Here is the info I use for bank booths and it works like a charm at the place I use it.:

with BankBooth do
begin
Col := 5008776;
Tol := 10;
Hue := 1.0;
Sat := 1.0;
Length := 100;
Width := 20;
Height := 5;
UpText := 'Bank'
end;

As you can see, I really didn't make -any- effort with tol, hue and sat. It's a time saver, really.


Thanks! Will practice using this, very useful ^^

Shatterhand

2013-02-12 01:32:20

Maybe combine the brown and grey color and exlude the TPAs which are less that MinPoints and more than MaxPoints. This is what I usually do.
SortATPASize(ATPA,False);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) > MaxPoints then
Break;
end;
if i = 0 then Exit;
SetArrayLength(ATPA,i);

InvertATPA(ATPA);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) < MinPoints then
Break;
end;
if i = 0 then Exit;
SetArrayLength(ATPA,i);

Sjoe

2013-02-12 01:41:48

From: Shatterhand
Maybe combine the brown and grey color and exlude the TPAs which are less that MinPoints and more than MaxPoints. This is what I usually do.
SortATPASize(ATPA,False);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) > MaxPoints then
Break;
end;
if i = 0 then Exit;
SetArrayLength(ATPA,i);

InvertATPA(ATPA);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) < MinPoints then
Break;
end;
if i = 0 then Exit;
SetArrayLength(ATPA,i);


What's the quicket/easiest way to determin how many points the tpa has?

Shatterhand

2013-02-12 07:08:12

From: Sjoekeloe
What's the quicket/easiest way to determin how many points the tpa has?

Length(TPA). Actually I used High(TPA) which is Length(TPA)-1. It does not matter.

Sjoe

2013-02-12 10:11:28

Thanks for the help guys!