SRL Archive - OSR Help

Need Help With FindObject!


Tehmoo

2013-06-11 21:06:32

My problem is not it actually finding the object it finds that perfectly. What it does is finds all of them but moves the mouse to all of them and tries to click all of them. Obviously what I want it to do is to choose one of the ones it finds and clicks it.

I looked at tutorials but I can't seem to put my mind together to figure it out, even if you point me in the right direction than actually doing it for me is just as nice.

I appreciate any help I can get.


function FindObject(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 0.12);

if not(FindColorsTolerance(arP, MineColor, MSX1, MSY1, MSX2, MSY2, 6)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 10.15) and (X <= 18.75) and (Y >= 12.39) and (Y <= 22.97) and (Z >= 16.87) and (Z <= 31.89) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
ClickMouse(P.x, P.y, mouse_Left);
if (IsUpText('Mine')) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;

EngageTheRage

2013-06-11 21:32:49

from a quick read through, it seems you are left clicking and then checking for upText which leads to break, surely you want to check upText then leftClick then break …

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
ClickMouse(P.x, P.y, mouse_Left);
if (IsUpText('Mine')) then
begin;
Result := True;
Break;
end;
end;

i believe should be:


for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
//ClickMouse(P.x, P.y, mouse_Left); // not here, otherwise you will move before upText is checked
if (IsUpText('Mine')) then
begin;
MouseClick2(True); // just a left click as no need to move mouse
Result := True;
Break;
end;
end;

Tehmoo

2013-06-11 21:34:23

Thank You very much EngageTheRage, I'll test it out in a bit.

Tehmoo

2013-06-12 11:36:27

I still have a problem with it clicking. It doesn't seem to be using
 if (IsUpText('Mine'))
so it won't click.
Also to mention this is for a private server but that really shouldn't be stopping it from not checking. the uptext. Also when I use MouseClick2(true) it gives me an identifier error, not sure if im missing an include somewhere.

Ian

2013-06-12 11:53:20

From: Tehmoo
I still have a problem with it clicking. It doesn't seem to be using
 if (IsUpText('Mine'))
so it won't click.
Also to mention this is for a private server but that really shouldn't be stopping it from not checking. the uptext. Also when I use MouseClick2(true) it gives me an identifier error, not sure if im missing an include somewhere.


Private servers have different uptexts so you'll have to make your own character set. Use
ClickMouse2(True);
to click.

Tehmoo

2013-06-12 11:58:00

Thank you, as for making the character set is there a tutorial for it. I'll look but in case I don't find one can you lead me to a link for it. That would be great.

Ian

2013-06-12 12:06:04

From: Tehmoo
Thank you, as for making the character set is there a tutorial for it. I'll look but in case I don't find one can you lead me to a link for it. That would be great.


There's a tutorial here. I haven't used it or made my own fonts before but Shuttleu has other tutorials that I've read which are good so I'm sure this one will be too :)

Tehmoo

2013-06-12 12:10:25

Thanks so much. I really appreciate it.

Ian

2013-06-12 12:15:13

From: Tehmoo
Thanks so much. I really appreciate it.


No problem, good luck with your script! :)