SRL Archive - OSR Help

Finding correct object with color


CephaXz

2012-05-02 01:52:33

I had a problem with finding the altar in my script. I have tried many colors but it changes too often, if tolerance is put higher, it will find the similar colors of the surroundings.
How can I find the color until the correct object is found?


There are 3 objects found with similar colors. The small stone and boots of lightness, and the altar that I want to find. How can I find the color until the object is found, or the uptext is there?

Here's the part that finds altar and clicks it.


Procedure ClickAltar6;
var
a,t: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box : TBox;
begin
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.84, 0.28);

//Find the color on mainscreen except your character, I know its crappy
if not FindColorsTolerance(TPA, 6906726, 0, 0, 231, 338, 2) then
begin
writeln('Trying to find area2');
if not FindColorsTolerance(TPA, 6906726, 0, 198, 515, 337, 2) then
begin
writeln('Trying to find area3');
if not FindColorsTolerance(TPA, 6906726, 274, 0, 515, 337, 2) then
begin
writeln('Trying to find area4');
if not FindColorsTolerance(TPA, 6906726, 0, 0, 515, 141, 2) then
begin
writeln('Cant find altar again omggggg');
writeln('Terminating Script');
TerminateScript;
end else
begin
writeln('Found in area4');
end;
end else
begin
writeln('Found in area3');
end;
end else
begin
writeln('Found in area2');
end;
end else
begin
writeln('Found in area1');
end;
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 15, 15);

for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
Box := IntToBox((MP.X - 20), (MP.Y - 20), (MP.X + 20), (MP.Y + 20));
{$IFDEF SMART}
SMART_DrawBoxEx(True, Box, clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 4, 4);
if WaitUptext('raft', 2000) then
begin
ClickMouse2(mouse_Left);
writeln('Crafting Runes');
MarkTime(t)
repeat
wait(500);
until WaitInvMaxCount(8, 2000) or (TimeFromMark(t) > 4000);
writeln('Crafted runes');
end else
begin
writeln('Y NO ALTAR?!?!');
TerminateScript;
end;
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
Break;
end;

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

iBlank

2012-05-02 02:08:12


Procedure CraftARune;
Begin
If (FindObj(x,y,'ltar',11318452,0) or FindObj(x,y,'ltar',9081233,0)) Then
Begin
Mouse(x,y,5,5,true);
End Else
Begin
WalkToAltar;
CraftARune;
End;
Wait(RandomRange(1250,1750));
IfRandoms;
End;

That is the function I use to search for the altar in my Astrals script. It searches for the lightest colored "rock" around the base of the altar and the darkest colored "rock" around the base. I don't believe it has failed me unless colors have changed!

Brandon

2012-05-02 02:11:08

if (CountColor(………) < 50) then
Continue;


Put that in your loop. OR you can sortatpafromsize(ATPA, 50, False); Which will sort from closest to you and largest first. Loop through the ATPA and mouse over it for the uptext.. If WaitUptextMulti(['altar', 'tar', 'stral'], 600) then…

J J

2012-05-02 05:56:28

If you can make sure to stand next to the altar you can make a smaller box where you want to be searching for
MSCX - 100, MSCY - 100, MSCX + 100, MSCY + 100

Nearly no-one seems to be using FindColoredArea but it works fairly well and is a lot easier to make than making TPA loops. If you know how to make those I highly suggest you to make TPA loops, though. But this code should work. Just edit the 499 and 500 numbers to whatever works well.
procedure Test;
begin
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(9.01, 9.00);
if CountColorTolerance(6972776, MSX1, MSY1, MSX2, MSY2, 2) > 499 then
begin
if FindColoredAreaTolerance(X, Y, 6972776, MSCX - 100, MSCY - 100, MSCX + 100, MSCY + 100, 500, 2) then
begin
MMouse(X, Y, 2, 2);
end;
end else
begin
WriteLn('We have counted less than 100 colors of our desired color');
//Failsafe here
end;
end;

Home

2012-05-02 06:17:05

You can use SortATPAFromMidPoint(aTPA, Point(SORTFROMTHISPOINT))


~Home

CephaXz

2012-05-03 00:37:49

Thanks guys. SortATPAFromSize works great for me!