PDA

View Full Version : Autocoloring / Object finding using TAutoColorInfo(TAI).



Sumilion
07-13-2008, 09:53 PM
As of SRL rev #18 we have a record in SRL called TAutoColorInfo. Basically this records holds a lot of parameters, which some functions can use to auto color or find an object.

As of rev #18 the TAutoColorInfo record looks like this :

type
TAutoColorInfo = record
Name: string;
Color: Integer;
MinCount: Integer;
MaxCount: Integer;
MaxDist: Integer;
MaxDistCenter: Integer;
UpText: string;
HueMod, SatMod: Extended;
LumTol: Integer;
MinR, MaxR, MinG, MaxG, MinB, MaxB: Integer;
MinX, MaxX, MinY, MaxY, MinZ, MaxZ: Extended;
end;

For those of you that do not know what a record is I suggest you read this tutorial (http://www.villavu.com/forum/showthread.php?t=9746?t=10966)

Basically we throw so many parameters at the function that you pretty much only get the color you want.

*note : just because TAutoColorInfo can contain all these values doesn't mean you have to fill them all in. However you do have to fill in most of them.

Using a TAutoColorInfo
Using a TAutoColorInfo is very simple and quick when you know what to do. Once you have loaded your TAutoColorInfo you can use it in any of the following functions :


function FindObjRecordEx(var fx, fy: Integer; AutoInfo: AutoColorInfo; QuickSorting, RGBXYZCheck: Boolean): Boolean;
function FindObjRecord(var fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean;
function FindColorRecordEx(var rx, ry: Integer; ColorRecord: TAutoColorInfo; x1, y1, x2, y2: Integer; RGBXYZCheck: Boolean): Integer;
function FindColorRecord(var rx, ry: Integer; ColorRecord: TAutoColorInfo): Integer;

*QuickSorting : With QuickSorting on the function divides the TPoints it found using TPAtoATPA, otherwise it uses SplitTPA. TPAtoATPA splits the points by taking one point, create a box around it and any point within that box belongs to that division. SplitTPA first looks at the first point, creates a box around it, much like TPAtoATPA, but then it looks at the second point in that division, creates a box around it, third point ... etc.

*RGBXYZCheck : With this on, it also checks the RGB and XYZ values, instead of just the HSL values.

Loading a TAutoColorInfo is just the same as loading any other record, here is an example of a varrockroad-TAutoColorInfo, using FindColorRecord we get the RoadColor.

program FindColorRecordExample;
{.include SRL\SRL.scar}

var
x, y: Integer;
ColorRecord: TAutoColorInfo;

begin
SetupSRL;

with ColorRecord do
begin
Name := 'Varrock Road';
MinCount := 100;
Color := 7633790;
HueMod := 0.63;
SatMod := 0.11;
LumTol := 8;
MinR := 106; MaxR := 146;
MinG := 102; MaxG := 144;
MinB := 97; MaxB := 136;
MinX := 13.10; MaxX := 25.89;
MinY := 13.69; MaxY := 27.43;
MinZ := 13.49; MaxZ := 26.86;
end;

Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
end.

Yes it is as easy as that, create your TAI (TAutoColorInfo) variable, load it and use the function. Here follows another example for finding the ladder on the main screen :

program FindObjRecordExample;
{.include SRL\SRL.scar}

var
x, y: Integer;
ObjectRecord: TAutoColorInfo;

begin
SetupSRL;

with ObjectRecord do
begin
Name := 'Main Screen Ladder';
UpText := 'Climb';
MaxDist := 15;
Color := 2838120;
HueMod := 0.09;
SatMod := 1.55;
LumTol := 4;
MinR := 95; MaxR := 122;
MinG := 69; MaxG := 90;
MinB := 33; MaxB := 53;
MinX := 7.28; MaxX := 11.91;
MinY := 6.96; MaxY := 11.41;
MinZ := 2.46; MaxZ := 4.71;
end;

FindObjRecord(x, y, ObjectRecord);
end.

*tip : Loading a TAI everytime you want to use it does not look very clean. It is advised to load it once globally, much like you load some bitmaps globally.

Creating a TAI
Now you might think how in the world am I supposed to get all those values :confused:. I agree, getting those manually is a pain in the *ss so I added a new function in ACA (AutoColorAid) that does the trick for you. If you have SRL rev#18 on your pc, in the standard location, ACA should be located here : C:\Program Files\SCAR 3.15\Includes\SRL\Scripting Tools\Auto Color Aid v2.exe . Unfamiliar with ACA ? Read this (http://www.villavu.com/forum/showthread.php?t=26944).

You simply follow the instructions in that thread but instead of creating a function you create a TAI through the FindColorRecord or FindObjRecord tabs.

TAI's in SRL
TAI's are already being used in SRL. The frog cave solver for examples uses some TAI's. This is all fine and dandy to know, but I guess it is hardly of any interest to you, what you however might like to know is the TAI's I've put in Mining.scar. There are 2 functions in Mining.scar,


function FindObjRockEx(var cx, cy: Integer; RockIndex: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
function FindObjRock(var cx, cy: Integer; RockIndex: Integer): Boolean;

You can use these using a couple of set TAutoColorInfo's in Mining.scar, just by telling what rock you want it to mine :eek:. Take a look at this script for example :

program New;
{.include SRL\SRL.scar}
{.include SRL\SRL\skill\Mining.scar}

var
x, y: Integer;

begin
SetupSRL
SetupMining;

FindObjRock(x, y, rimmington_Iron);
end.

That will find rimmington iron rocks. Here is the list with all possible entries for the rock index (in the example this is rimmington_Iron) :


rimmington_Clay
rimmington_Copper
rimmington_Tin
rimmington_Iron
rimmington_Gold

old_Clay
old_Copper
old_Tin
old_Iron
old_Coal
old_Mithril
old_Adamant

varrock_Clay
varrock_Copper
varrock_Tin
varrock_Iron
varrock_Silver

lumbridge_Copper
lumbridge_Tin
lumbridge_Coal
lumbridge_Mithril
lumbridge_Adamant

falador_Clay
falador_Copper
falador_Tin
falador_Iron
falador_Coal
falador_Mithril
falador_Adamant

I can imagine all of this may sound a bit like a foreign language to some people, if you need any clarification on some topic please do post here and I will adjust the tutorial.

Claymore
07-13-2008, 10:22 PM
Amazing! Thanks SRL Dev and Sumilion! Looks like I can test this out on my upcomming Power Or Bank Multi - Mine! You guys are AWSOME!

Rubix
07-13-2008, 11:34 PM
wow that is just what i need for lumby stairs!
E: You need to update ACA?

Sumilion
07-14-2008, 11:27 AM
wow that is just what i need for lumby stairs!
E: You need to update ACA?

Yeh the one that is in rev #17 or the one that you can download here on the forums will not have this function.

Claymore
07-14-2008, 03:22 PM
what with the mincount and lumtol? i know part of lumtol means tolerance =p

ShowerThoughts
07-14-2008, 03:26 PM
GOOD Job Mate, Damn Good Job!

Rubix
07-15-2008, 04:01 PM
without this, i wouldnt have been able to finish my flax spinner :P finds the stairs, the spinning wheel, and even finds the "spin bowstring" button 1337

Sumilion
07-15-2008, 04:42 PM
what with the mincount and lumtol? i know part of lumtol means tolerance =p

LumTol = LumTol
HueTol = HueMod * LumTol
SatTol = SatMod * LumTol

familiar with the HSL color range ? If not I suggest searching for a tutorial here.

Mincount is the minimum amount of pixels an object should have before it will move the mouse to it, or the minimum amount something must have before it is a valid color (in FindColorRecord(Ex)).

Scaper
07-15-2008, 05:52 PM
wow very nice and very hand

good job man ;)

HyperSecret
07-15-2008, 06:19 PM
This will be fun to work with, good job!

ShowerThoughts
07-15-2008, 06:22 PM
LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/

Harry
07-15-2008, 06:24 PM
LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/

Delete SRL Folder && checkout SVN.


Epic tut Sumilionio.

Claymore
07-15-2008, 11:02 PM
I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)


function LightingPoint : Boolean;
var
x, y : Integer;
ColorRecord : TAutoColorInfo;
begin
if (not (LoggedIn)) then Exit;
with ColorRecord do
begin
Name := 'Camelot Road';
MinCount := 50;
Color := 7697533;
HueMod := 0;
SatMod := 0;
LumTol := 5;
MinR := 42; MaxR := 82;
MinG := 52; MaxG := 92;
MinB := 6; MaxB := 46;
MinX := -10; MaxX := 20;
MinY := -9; MaxY := 21;
MinZ := -13; MaxZ := 17;
end;
Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;
RoadColor := FindColorRecord(x, y, ColorRecord);
RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);
FFlag(2);
Wait(330 + Random(275));
Result := True;
end;



Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.



****** ******
Creating the NickTPA.
0
________________________________________
[ ]
[ Maple Forest Fire Progress ]
[ Report Version 1 ]
[ Time Elapsed : 1 Minutes and 1 Seconds
[ Loads Finish : 0
[ Ents Found : 0
[ Loads Banked : 0
[ Loads Burnt : 0
[ Please Post This Report! ]
[______________________________________]
******* *******
0


So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.



Color Picked: 7500411 at (651, 105)


........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!

Wizzup?
07-15-2008, 11:14 PM
XYZ range from 0 to 100, they never go negative. :)

Macro_FTW
07-15-2008, 11:28 PM
Great tutorial. Can you please elaborate on the following values, please?
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script. :D

~Macro

Claymore
07-16-2008, 12:43 AM
XYZ range from 0 to 100, they never go negative. :)

But i read a guide

-20 for RGB
-15 XYZ
-10 for i forgot the other one, HSL i think.

But thanks Wizzup?!

Method
07-16-2008, 03:05 AM
Great tutorial. Can you please elaborate on the following values, please?
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script. :D

~Macro

With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).

Sumilion
07-16-2008, 09:48 AM
I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)


function LightingPoint : Boolean;
var
x, y : Integer;
ColorRecord : TAutoColorInfo;
begin
if (not (LoggedIn)) then Exit;
with ColorRecord do
begin
Name := 'Camelot Road';
MinCount := 50;
Color := 7697533;
HueMod := 0;
SatMod := 0;
LumTol := 5;
MinR := 42; MaxR := 82;
MinG := 52; MaxG := 92;
MinB := 6; MaxB := 46;
MinX := -10; MaxX := 20;
MinY := -9; MaxY := 21;
MinZ := -13; MaxZ := 17;
end;
Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;
RoadColor := FindColorRecord(x, y, ColorRecord);
RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);
FFlag(2);
Wait(330 + Random(275));
Result := True;
end;



Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.



So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.



........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!

Yes I'd suggest recreating the TAI using ACA v2 cause that TAI is just not right. Not only the XYZ are negatives, but the Hue and Sat mods are 0, which means Hue Tolerance is 0 and Saturation Tolerance is 0, which in turn means it will not find many colors, most likely only 7697533 and if it won't find any color it returns 0.


Great tutorial. Can you please elaborate on the following values, please?
QuickSorting
RGBXYZCheck

Thanks. This will definately help in my tutorial island script. :D

~Macro


With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).

He is right, I also added a small explanation at the first post about it.

Claymore
07-16-2008, 03:20 PM
Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.

Sumilion
07-16-2008, 04:38 PM
Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.

True, then you have only selected one color. The power of ACA lies in the ability to take the average from all the colors you've put in, and calculate what tol it needs to be similar to each color you've put in. So the more colors you've entered in ACA, the bigger the chance it will find the color you want. You're using ACA to find the road color ? I suggest going into a world, pick the road color, logout + login, pick it again, switch worlds and repeat.

Claymore
07-16-2008, 09:19 PM
Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon. ;)

Sumilion
07-16-2008, 11:11 PM
Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon. ;)

Will you now ? :p glad I could help

lordsaturn
07-22-2008, 05:06 AM
What's the advantage of using this over normal autocoloring/object finding?

Sumilion
07-22-2008, 11:01 AM
Its fast to make and easily adjustable.

Claymore
07-22-2008, 10:02 PM
Is it the same reliability as a regular Auto Color?

And also, i got accepted in SRL Members! Check me out! Look so cool. (You can see the difference =3)

Method
07-22-2008, 10:53 PM
Is it the same reliability as a regular Auto Color?

And also, i got accepted in SRL Members! Check me out! Look so cool. (You can see the difference =3)

It's however reliable YOU make it. You're responsible for filling in the color, tolerance, ranges, etc. so it all falls on you to make it work. The finding itself should work fine as long as you fill in the information correct, though.

Awkwardsaw
07-31-2008, 01:47 AM
how do you put it in a script and make it click the color? iv been studying your ACA funtion for auto color, and the findobject funtion, i cant figure it out

Sumilion
07-31-2008, 08:59 AM
Example for autocoloring :

program FindColorRecordExample;
{.include SRL\SRL.scar}

var
x, y, tmpColor: Integer;
ColorRecord: TAutoColorInfo;

procedure LoadRecords;
begin
with ColorRecord do
begin
Name := 'Varrock Road';
MinCount := 100;
Color := 7633790;
HueMod := 0.63;
SatMod := 0.11;
LumTol := 8;
MinR := 106; MaxR := 146;
MinG := 102; MaxG := 144;
MinB := 97; MaxB := 136;
MinX := 13.10; MaxX := 25.89;
MinY := 13.69; MaxY := 27.43;
MinZ := 13.49; MaxZ := 26.86;
end;
end;

begin
SetupSRL;
LoadRecords;

tmpColor := FindColorRecord(x, y, ColorRecord);

if FindColor(x, y, tmpColor, MMX1, MMY1, MMX2, MMY2) then
begin
Mouse(x, y, 0, 0, True);
Flag;
end;
end.

Example for Object finding :

program FindObjRecordExample;
{.include SRL\SRL.scar}

var
x, y: Integer;
ObjectRecord: TAutoColorInfo;

procedure LoadRecords;
begin
with ObjectRecord do
begin
Name := 'Main Screen Ladder';
UpText := 'Climb';
MaxDist := 15;
Color := 2838120;
HueMod := 0.09;
SatMod := 1.55;
LumTol := 4;
MinR := 95; MaxR := 122;
MinG := 69; MaxG := 90;
MinB := 33; MaxB := 53;
MinX := 7.28; MaxX := 11.91;
MinY := 6.96; MaxY := 11.41;
MinZ := 2.46; MaxZ := 4.71;
end;
end;

begin
SetupSRL;
LoadRecords;

if FindObjRecord(x, y, ObjectRecord) then
Mouse(x, y, 0, 0, True);
end.

hope this is what you mean ?

NiCbaZ
07-31-2008, 09:18 AM
when i try and generate the function on ACA i get CTS 2 in not enabled helps?

Awkwardsaw
07-31-2008, 12:56 PM
Example for autocoloring :

hope this is what you mean ?

yepp :) thanks,

and the work continues on my MTA script..

(if using these procedures wont hurt my chance getting into members, since both of those are in ACA)

Sumilion
07-31-2008, 01:19 PM
when i try and generate the function on ACA i get CTS 2 in not enabled helps?

Then select CTS 2 :p, you can do so at the bottom right group box.

JPHamlett
03-11-2009, 11:36 PM
is there any way to amke it click on the rock im mining