SRL Archive - OSR Help

Better object finding


Yanhua

2011-12-20 21:41:12

Hello fellow scripters,

I'm currently in the process of improving my Swamp Toad collector script.

One major flaw in my script is the locating/clicking of toads on the ground.


As you can see, the toads are extremely small and similar in colour to the grass around. At the moment I'm using FindObjCustom to locate them. It does find them eventually, but is extremely bot-like, chunky and slow.

Have any of you got suggestions on a better function to use? I'm just a beginner and would love it if you could explain how.

Cheers :D

YoHoJo

2011-12-20 21:52:57

Hey I'm only F2P can you either upload a picture of better quality, (in the picture please have 1 item in your inventory) or, let me borrow the account for a second please?

Yanhua

2011-12-20 21:56:33

From: YoHoJo
Hey I'm only F2P can you either upload a picture of better quality, (in the picture please have 1 item in your inventory) or, let me borrow the account for a second please?


Sure YoHoJo, PMing you the details now.

YoHoJo

2011-12-20 22:33:17

BYAM BITCH!
Not too hard, but kind of :/.

Here is the link to the ACA file:
http://up.ht/tymLl4
So you can add/remove colors as you wish.

If you don't already know, learn about/download auto color aid here:
http://villavu.com/forum/showthread.php?t=26944

If you are lazy and need results NAO you can just use this code:
function FrogColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.59, 0.16);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2521930, MSX1, MSY1, MSX2, MSY2, 3);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (X >= 8.05) and (X <= 13.07) and (Y >= 12.87) and (Y <= 19.35) and (Z >= 3.63) and (Z <= 5.16) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

Basically paste that into your script before your frog finding function.
And lets say you're using Findcolor, you would just enter 'FrogColor' where the color parameter is, example:
  If FindColor(X, Y, FrogColor, MSX1, MSY1, MSX2, MSY2) Then
Begin
Writelb('FROG!');
MMouse(x,y 1, 1);
If IsUpText('fr') Then
Mouse(X, Y, 0, 0, True)
End;

All done with your account now, feel free to change password or whatever.

Yanhua

2011-12-20 22:35:39

From: YoHoJo
BYAM BITCH!
Not too hard, but kind of :/.

Here is the link to the ACA file:
http://up.ht/tymLl4
So you can add/remove colors as you wish.

If you don't already know, learn about/download auto color aid here:
http://villavu.com/forum/showthread.php?t=26944

If you are lazy and need results NAO you can just use this code:
function FrogColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.59, 0.16);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2521930, MSX1, MSY1, MSX2, MSY2, 3);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

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

if (X >= 8.05) and (X <= 13.07) and (Y >= 12.87) and (Y <= 19.35) and (Z >= 3.63) and (Z <= 5.16) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

Basically paste that into your script before your frog finding function.
And lets say you're using Findcolor, you would just enter 'FrogColor' where the color parameter is, example:
  If FindColor(X, Y, FrogColor, MSX1, MSY1, MSX2, MSY2) Then
Begin
Writelb('FROG!');
MMouse(x,y 1, 1);
If IsUpText('fr') Then
Mouse(X, Y, 0, 0, True)
End;

All done with your account now, feel free to change password or whatever.


THANK YOU YOHOJO! :D :) ++REP!!

Never really looked into the ACA, will do that now!

Yanhua

2011-12-20 23:16:52

I've ran into a problem here :(

Even though Mark Color and Mark Best Color finds the toads perfectly in ACA, it doesn't seem to work at all in the real RS client.

Tried both your colours and I also tried making my own. Only result is AutoColor failed in finding the color.

E: Figured out the problem! WORKS FLAWLESS NOW :D